I'm just starting to learn C++ coming from C and I am hitting a bit of a roadblock right off the bat. Writing this simple program to print input from a text file line by line gives no console output whatsoever, not even the lines that should be printed regardless of the files content. What gives? Using endl to flush the buffer seems to have no effect.
using namespace std;
#include <iostream>
#include <fstream>
#include <string>
void readFile(ifstream& file) {
string word;
int c = 0;
while( file >> word) {
cout << word << endl;
c++;
}
cout << "Read " << c << " words." << endl;
}
int main() {
cout << "Will open file." << endl;
ifstream file;
file.open("testscene.txt");
if(!file.is_open()) {
cout << "File not found!" << endl;
return 0;
}
readFile(file);
return 0;
}