Part A of my assignment was to read a file from disk and write all of the integers to the output file on one line. The input file was 4 lines long. My integers are all on one line with the following code, however, you don't know where one integer end and the other begins. What am I doing wrong or is there no other way?
Code:#include<iostream> #include<fstream> using namespace std; int main() { //Declare and open files ifstream inFile; ofstream outFile; //Declare variables char inChar; inFile.open ("K:\\DATFILE1.TXT"); outFile.open ("K:\\ANSWERS.TXT"); if ( !inFile ) { cout<< "**Can't open input file**" <<endl; return 1; } inFile >> inChar; while (inFile) { outFile << inChar; inFile >> inChar; inFile.close(); return 0; }