#include <fstream>
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

void output_chrs(char , char , char , char , char , char , char );
void output_ints(int , int , int , int , int , int , char );
void output_strs(string , string , string , string , string , string , char );

int main()
{
ifstream in_file;

char a,b,c,d,e,f, ch1;
int aa, bb, cc, dd, ee, ff;
string aaa, bbb, ccc, ddd, eee, fff;

a = b = c = d = e = f = ch1 = '#';
aa = bb = cc = dd = ee = ff = -1;
aaa = bbb = ccc = ddd = eee fff = "";

// Open a file
in_file.open("problem4.txt");
// Read into char variables
in_file >> a >> b >> c;
in_file.ignore(100,'\n');
// get a single char
in_file.get(ch1);
// read more chars
in_file >> d >> e >> f;
in_file.ignore(100,'\n');
in_file.ignore(100,'\n');
// read into chars a and b again
in_file >> a >> b;
// close the file
in_file.close();
// output the contents of the variables
output_chrs (a, b, c, d, e, f, ch1);

// open the same file again and read into integers except char ch1
in_file.open("problem4.txt");
in_file >> aa >> bb >> cc;
in_file.ignore(100,'\n');
in_file.get(ch1);
in_file >> dd >> ee >> ff;
in_file.ignore(100,'\n');
in_file.ignore(100,'\n');
in_file >> aa >> bb;
in_file.close();
output_ints (aa, bb, cc, dd, ee, ff, ch1);

// Open the file again, and read into strings, except char ch1
in_file.open("problem4.txt");
in_file >> aaa >> bbb >> ccc;
in_file.ignore(100,'\n');
in_file.get(ch1);
in_file >> ddd >> eee >> fff;
in_file.ignore(100,'\n');
in_file.ignore(100,'\n');
in_file >> aaa >> bbb;
in_file.close();
output_strs (aaa, bbb, ccc, ddd, eee, fff, ch1);

return 0;
}


void output_chrs(char p1, char p2, char p3, char p4, char p5,
                 char p6, char p7)
{
cout << "As Chars:\na,b,c;\nd,e,f;\nch1;\n";
cout << p1 << "," << p2 << "," << p3 << ";\n";
cout << p4 << "," << p5 << "," << p6 << ";\n";
cout << p7 << ";\n";
}

void output_ints(int p1, int p2, int p3, int p4, int p5,
                 int p6, char p7)
{
cout << "As Ints (except ch1):\na,b,c;\nd,e,f;\nch1;\n";
cout << p1 << "," << p2 << "," << p3 << ";\n";
cout << p4 << "," << p5 << "," << p6 << ";\n";
cout << p7 << ";\n";
}

void output_strs(string p1, string p2, string p3, string p4, string p5,
                 string p6, char p7)
{
cout << "As Strings (except ch1):\na,b,c;\nd,e,f;\nch1;\n";
cout << p1 << "," << p2 << "," << p3 << ";\n";
cout << p4 << "," << p5 << "," << p6 << ";\n";
cout << p7 << ";\n";
}
