|
C++ file I/O
So, how would I fix the following code to work? I _can_ get it to work if I change the definition:
char* city[2][11];
to:
char city[2][11][21];
and some other minor changes in code. The thing is I don''t want to do this. Please help!
/john
*Save GameDev - donate*
Works fine for me, except that you may want to use vector and string (and getstring). You are also returning 1 from main, indicating an error occured, this might be a bit pessimistic.
Dos/windows never checks anyway.
Dos/windows never checks anyway.
The reason it doesn''t work is because you have an array of 2 arrarys of 11 character arrays.
char city[2][11][21];
Is the correct way to do it because you have the 2 representing how many layers there are, the 11 representing how many lines there are, and the 21 representing how many columns (characters in each line) there are.
char city[z][y][x] is your coordinate system so you dont only want to use char city[z][y]
char city[2][11][21];
Is the correct way to do it because you have the 2 representing how many layers there are, the 11 representing how many lines there are, and the 21 representing how many columns (characters in each line) there are.
char city[z][y][x] is your coordinate system so you dont only want to use char city[z][y]
Grib:
When I compile and run I get an access violation in LoadMap (the cin.getline-line).
--
Moreover, I''ve never really used vectors (or have i?) and strings. ... help?
/john
*Save GameDev - donate*
When I compile and run I get an access violation in LoadMap (the cin.getline-line).

--
Moreover, I''ve never really used vectors (or have i?) and strings. ... help?
/john
*Save GameDev - donate*
What he means by vectors is the STL array equivalent which are called vectors. Very powerful stuff indeed.
" The fastest code is the code you don't call "
August 18, 2001 03:28 AM
ok here is what is going on...
when you do it like that, the compiler points to the TEMPORARY memory that was allocated in order to hold the text you had. then when you try to access it, its not there because the memory is TEMPORARY!!! that is why you need the a 3D array and not a 2Darray, so it can ALLOCATE AND KEEP the memory and not just ALLOCATE TEMPORARILY.
hope that helps a little
when you do it like that, the compiler points to the TEMPORARY memory that was allocated in order to hold the text you had. then when you try to access it, its not there because the memory is TEMPORARY!!! that is why you need the a 3D array and not a 2Darray, so it can ALLOCATE AND KEEP the memory and not just ALLOCATE TEMPORARILY.
hope that helps a little
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement