1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
string filename;
int a, b, c; // ASCII values for fill character
int aw, bw, cw; // width values for setwidth
char ch1, ch2, ch3; // character for right or left justification
string s1, s2, s3; // strings
ifstream inData;
ofstream outData;
cout << "please enter the location of the file you wish to input: " << endl;
getline(cin, filename);
inData.open(filename.c_str());
outData.open("Last_First_proj1.results.txt");
inData >> a;
inData.ignore(100, ' ');
inData >> aw;
inData.ignore(100, ' ');
inData >> ch1;
inData.ignore(100, ' ');
getline(inData, s1);
inData >> b;
inData.ignore(100, ' ');
inData >> bw;
inData.ignore(100, ' ');
inData >> ch2;
inData.ignore(100, ' ');
getline(inData, s2);
inData >> c;
inData.ignore(100, ' ');
inData >> cw;
inData.ignore(100, ' ');
inData >> ch3;
inData.ignore(100, ' ');
getline(inData, s3);
{
if (ch1 == 'l' || ch1 == 'L')
outData << left;
else if (ch1 == 'r' || ch1 == 'R')
outData << right;
else
outData << "error" << endl;
}
outData << setw(aw) << setfill(char(a)) << s1 << endl;
{
if (ch2 == 'l' || ch2 == 'L')
outData << left;
else if (ch2 == 'r' || ch2 == 'R')
outData << right;
else
outData << "error" << endl;
}
outData << setw(bw) << setfill(char(b)) << s2 << endl;
{
if (ch3 == 'l' || ch3 == 'L')
outData << left;
else if (ch3 == 'r' || ch3 == 'R')
outData << right;
else
outData << "error" << endl;
}
outData << setw(cw) << setfill(char(c)) << s3 << endl;
inData.close();
outData.close();
return 0;
|