#include <iostream>
#include <fstream>
using namespace std;
void get_input (ifstream& ifile){
std::string filename;
cout << "Input filename:";
cin >> filename;
if (ifile.fail()){
cout << "File is not found"<< endl;
}
int ID, score, count = 0;
while (1){
ifile >> ID >> score;
if (ifile.eof()) break;
++count;
}
ifile.close();
cout << ID << endl;
cout << count << endl;
cout << score << endl;
}
main:
int main(int argc, const char * argv[]) {
ifstream file;
get_input (file);
return 0;
}
I changed it to std::string, but the counter still prints out 0. I am taking int data from a file that has 2 columns. I also need to count the number of lines in the file.