C++ Main file does not display everything
My program read a *.txt file and prints a line from the file backwards. i
wanted to get the linenumber before it does so. after doing the loop, i
got my number, but everything after my "for loop" is not printing/
working. what is wrong with my code?
#include "oneLine.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
OneLine aline;
ifstream testFile ("test.txt");
if (testFile.good()) {
int countLines = 0;
string temp;
for (int i = 0; getline(testFile, temp); i++)
countLines++;
cout << countLines;
aline.readLine(testFile);
aline.breakLine();
aline.printReverse();
//int a = aline.totalLines(testFile);
} else {
cout << "Error: Invalid File.";
}
return 0;
}
No comments:
Post a Comment