for some reason file won't read my data

Data name is cardnumbers.txt
data here
4120670000624855
4266901024841678
6011002543517833
6011208947684752
5545141002153628
4403190016296308
6011208997992451
8466160241276433
4313072843714489
5121079602112358
4403190015929676
5581588012277612
5466160341276433
4313072843777890

this is my coding down here I did exactly what book showed but doesn't work it doesn't read file. And yes I put text file same place as cpp file.

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int main()
{
ifstream cardinfo;
int cardnumber;
//string card_name;
cardinfo.open("cardnumbers.txt");
while (cardinfo >> cardnumber)
{
cout << cardnumber << endl;
}
cardinfo.close();
return 0;
}
Last edited on
Im not sure but those numbers are way to high to be read by an integer. I see you commented out the string, did you try that?
change
int cardnumber;
to
long long int cardnumber;
jae0014 please use code Brackets
Topic archived. No new replies allowed.