Click to See Complete Forum and Search --> : How to read ints from a text file


September 21st, 2001, 12:22 PM
for instance like:
12 32 323 342
12 3213 23 12
and store them into a array

Igor Soukhov
September 21st, 2001, 02:25 PM
Something like this:


#include <fstream>
using std::ifstream;

int main()
{
char *filename = "in.txt";
ifstream in(filename);

int ar[1000];
int i = 0;

while (in)
{
in >> ar[i++];
}

return 0;
}





Please - rate answer if it helped you
It gives me inspiration when I see myself in the top list =)

Best regards,

-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com

Member of Russian Software Developer Network http://rsdn.ru

September 22nd, 2001, 12:34 PM
thank you