reading from file
i want to have an 2d array:
map[100][100];
and a file that contains something like:
0123456789
----------
0 |11121102101010210210102
1 |11121102101010210210102
2 |11121102101010210210102
3 |11121102101010210210102
4 |11121102101010210210102
then i want to put that in the array...
so map[0][0] == 1, map[7][0] == 2
can someone help me?
You have to open (in binary) file that contains your map definition and load that thing into memory - probably you have problems with file handling...?
ok well with this case i dont see whats wrong with just your run of the mill ifstream to read in the file then if you really need to you can just take the string and divide it into sections like so
string[Y] FileReader = //read file in here
if(X = 10)
{
Y++;
};
//also there is a function that will then that array of string"int" into actual ints then you could put those in an array and your set
ok im not in a place were i have the documintation for this set of functions (file reading) on hand but thats the genral idea so if some one could elaborate a little more on what i wrote i would appriciate it (that is if this is what he is looking for)
string[Y] FileReader = //read file in here
if(X = 10)
{
Y++;
};
//also there is a function that will then that array of string"int" into actual ints then you could put those in an array and your set
ok im not in a place were i have the documintation for this set of functions (file reading) on hand but thats the genral idea so if some one could elaborate a little more on what i wrote i would appriciate it (that is if this is what he is looking for)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement