for loop - Need help assigning .txt characters into a 2d array. C++ -


i'm working on school project involves taking pre-designed 25x25 maze .txt file , inputting 2 dimensional array, printing onto console , moving character through maze. main issue i'm having moving characters array. feel i'm close code have causes program crash.

here's loop i'm using move characters array:

int col=0; ifstream infile; infile.open("maze.txt"); char temp = infile.get(); while(!infile.eof()) {     for(int row=0; row<25; row++)     {         while(temp != '\n')         {             boundary[row][col] = temp;             col++;             temp=infile.get();         }         temp=infile.get();     } } infile.close(); 

essentially, point move both spaces , block characters 25x25 character array taking characters in each row same row of array until reaches new line character, should move next character on next row , start while loop again.

it compiles fine, program crashes before can move other code. if know how fix without drastically changing format i'd appreciate because small part, i'm open starting scratch if need to.

reset col 0 after each row (before or after while(temp != '\n') loop).


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -