   File IO/2D array
  Alright im trying to recreate pacman and ive hit one problem. Im storing the map layouts in a text file called map.txt . I open the file fine and can extract the lines i need, but i want to save them into the 2D current map array. ex. //map_text is the current line, current_map[][] is the array (30x20)//how do i do something like thiscurrent_map[x][y] = map_text (so that that on x line it has the y values from the text file)sorry if its confusing 
  Are you using C or C++? I would give different recommendations for the two different languages. Also, is your map file always 30 x 20 or do you plan to have varying map sizes? And the variable type of your current_map array is also something that would factor into the solution. If current_map is an array of ints it would probably be much easier to load than, for example, an array of cows.One generic piece of advice: try to think how you would write the file if you had current_map loaded already, and then try to do the reverse of that. ;  Oh man, that reminds me of the days when I used arrays of cows. What was I thinking back then? I even experimented with sheep, but lets face it, all that wool is bound to play havoc with the compiler.When I started work on my first TileEngine I used a text file that contained a block of numbers like so...111111111110000000011000000001100000000110000000011111111111My CMap object contained a 2D array of ints to store those values which I could then use for simple collision detection. Take note: the engine never did any more than coloured squares, it was just an experiment. Anyway, I read in the contents of that file one char at a time. Each time I did so, I converted it to an int and assigned it to the appropriate element. void CMap::loadMap(char *filename){FILE *mapfile = fopen(filename,"r");  char x;  int n; for (int i = MAP_HEIGHT-1; i > -1; i--){for (int j = 0; j < MAP_WIDTH+1; j++){x = getc(mapfile);    n = atoi(&x);if (j != MAP_WIDTH)// the return line is read and must be ignored{Tiles[j][i].init((float)(j * TILE_WIDTH) + TILE_WIDTH_HALF, (float)(i * TILE_HEIGHT) + TILE_HEIGHT_HALF);Tiles[j][i].mType = (float)n;}}}fclose(mapfile);}It was a fairly lazy setup and there was no error checking but it did the job. In order to get it working I first of all got it reading a single char from a file and assigning it to a single tile. Then I got it to read a line and ensured that was done inside a loop. Once that was mastered I repeated the procedure to get it reading in multiple lines (one char at a time still) until I eventually had it taking care of the whole map.By all means take that code I''ve provided, but I would recommend you try and take the steps I did.Good luck. ;  here is some more info: im using C++ and the array is of integers, and yes it is constant for every game. The game is pacman and the array is basically 1 or 0 for now, 0 representing clear, 1 a wall. So obviously it is just a matter of loading 1 and 0 into the array (yeah i know what about powerups and stuff, ill be able to easily do them later with higher numbers. ie. 2-powerup)Thanks for the idea m_wherrett im going to try it as soon as i get home from school 