Need help with maze program.

This is a discussion on Need help with maze program. within the C Programming forums, part of the General Programming Boards category; I am working on a maze assignment. We are supposed to read in the text file that contains the maze, ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Need help with maze program.

    I am working on a maze assignment. We are supposed to read in the text file that contains the maze, which looks like the one below, and convert it to a graph/ grid. I can get it to read in the file, but cant figure out what to do next. Any help would be appreciated. I'm not necessarily looking for code.
    This is what I have so far.

    Code:
    int main(){
    	FILE *myfile;
    	char c;
    
    	myfile = fopen("maze2.txt", "r+");
    
    	if(!myfile){
    	   printf("File not found.");
    	}
    
    	do{
    
    		c = fgetc(myfile);
    		putchar(c);
    	}
    	while(c!= EOF);
    	fclose(myfile);
    	node_t maze;
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Nov 2009
    Posts
    46
    what your input file looks like?

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    15
    ooooooooooo
    o*********o
    o*ooooooo *o
    o+o*******o
    ooo* ooooooo
    o$o******$o
    o*o*ooooooo
    o********-o
    ooooooooooo

    The * are blank spaces
    + and - are the start and finish
    $ are checkpoints

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    46
    just declare 2d array of char, and two integers i and j
    i=0, j=0;
    using getchar() increase j, if you see '\n' -> increase i and j=0.

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    15
    I'll try that , thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  2. Help my c++ program
    By cal_cyrus in forum C++ Programming
    Replies: 0
    Last Post: 05-21-2007, 02:24 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21