Sign in to follow this  
peb

reading from file

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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...?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this