-
arrays and files
ok here is the code i got
Code:
fin.open("map2.txt");
while(!fin.eof());
{
fin >> szMap[x][y];
cout<<szMap[x][y]<<endl;
}
the problem is well alot of things i think... the file is initialised szMap[37][37]; and the length of the first and only line in map2.txt is 37 characters long and x and y are set to 0 for the time being... besides wondering how to fix the compile errors would this work? and how would i load say
xxxxx
xxxxx
xxxxx
into array szMap[][] from a file? because the example i have posted only loads one line (that im aware of)
thx for any and all help
-
add the line - x++;
at the end of your loop...
and from my understanding y should be zero
Code:
x 0 1 2 3 //x1 points (x1)y0...x2 points to x2(y0)...etc...
y
0 L L x e
1 I I x t
2 N N x c
3 E E x .
4 1 2 x \0
5 \0 \0 \0
-
> while(!fin.eof());
Why this is a "bad thing" is in the FAQ
-
anyone know of a good file i/o tutorial because so far i have just been copying parts of examples...