I am trying to read integers located in a dat file. I thought that this is the correct way to approach this problem but nothing prints out to the console and when I try to print out an index from vector nothing shows up indicating that nothing is actually being store in the vector. I would appreciate any help. Thank you!
vector<int> nums;
ifstream myfile;
myfile.open("nums.dat");
int a = 0;
while (myfile >> a) {
nums.push_back(a);
}
for (int i = 0; i < nums.size(); i++) {
cout << nums.at(i) << endl;
}
return 0;