I dont know how to transpose the file then write it in the output file
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<sstream>
using namespace std;
const int arxSize = 10;
ifstream inFile;
int i, ID = 0;
int main()
{
string b = "";
string ifilename, line, ofilename;
ifstream inFile, checkOutFile;
ofstream outFile;
char response;
// Input file
cout << "Please enter the name of the file you wish to open : ";
cin >> ifilename;
inFile.open(ifilename.c_str());
if (inFile.fail())
{
cout << "The file " << ifilename << " was not successfully opened." << endl;
cout << "Please check the path and name of the file. " << endl;
exit(1);
}
else
{
cout << "The file is successfully opened." << endl;
}
// Output file
cout << "Please enter the name of the file you wish to write : ";
cin >> ofilename;
checkOutFile.open(ofilename.c_str());
if (!checkOutFile.fail())
{
cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : ";
cin >> response;
if (tolower(response) == 'n')
{
cout << "The existing file will not be overwritten. " << endl;
exit(1);
}
}
outFile.open(ofilename.c_str());
if (outFile.fail())
{
cout << "The file " << ofilename << " was not successfully opened." << endl;
cout << "Please check the path and name of the file. " << endl;
exit(1);
}
else
{
cout << "The file is successfully opened." << endl;
}
// Copy file contents from inFile to outFile
cout << "Please enter the last 5 digits in your student ID : ";
cin >> ID;
cout << " " << endl;
cout << "The numbers from the input file with added last row." << endl;
while (getline(inFile, line))
cout << line << endl;
if (ID < 0)
ID = -ID;
stringstream ss;
ss << ID; //convert to individual numbers
ss >> b;
for (int i = 0; i < b.length(); ++i)
{
cout << b[i] << " ";
}
cout << " " << endl;