#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
const int stid = 20102265;
string ifilename, ofilename, line;
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
while(getline(inFile, line))
{
cout << line << endl;
outFile << line << endl;
}
{
cout << "Student ID : " << stid << endl;
char array[stid]; *****THIS IS WHERE IM CONFUSED*****
}
// Close files
inFile.close();
outFile.close();
} // main
how do i make the stid into an array. i know i need to do % to break the 8 integer up into 3 numbers but i'm confused
When i overwrite input11.txt to output11.txt i need creat an array for those 7 integer numbers on the output.11txt file then i need to creat and store my 8 number student id into an array so i can put it back into output11.txt
I guess what im having trouble on is how to create an array mid-file