News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Maze problem

Started by 00bob, December 07, 2011, 11:52:45 PM

Previous topic - Next topic

00bob

    Ok so my final is to open up a maze for a .dat file. And make a program that executes through the maze and records the moves. Right now I can't even get step one to work. I know I have to open up the file first but for some reason I can't get it to open properly. So i have to open the files the teacher gave me then write code to navigate the maze he gave me.

Here is what i have

   
   
   
    #include <stdio.h>
     
     int main()
     {
        FILE *fp;
        const char *fname;
        fname = "c:\\users\\austin\\documents\\computer_programing_cita_180\\pelles c projects\\reamaze";
        fp = fopen (fname, "r");
        fscanf(fp, "%s",);
        feof(fp)
     
     
     
     
    fclose (fp);
     return 0;
     }


CommonTater

#1
As we told you on C++ Programming... put the data file in the same folder as your executable file.

Then all you need is the filename, you can get rid of the path entirely...

As in...

fopen("reamaze.dat","r");


We also explained about checking return values to be sure the file is opening...

FILE *fp;

fp = fopen("reamaze.dat","r");
if (! fp)
  { printf("The file did not open");
     return 1; }





Also we told you about the change in windows settings to unhide your file extensions...
Control Panel -> Folder Options -> View -> Uncheck "Hide extensions of known file types".
Turn that off and leave it off.

It is very likely your file isn't named simply "reamaze"... it's probably "reamaze.txt" or something similar.

Finally, we told you repeatedly to look stuff up in the Pelles C help files... it's a total documentation of almost everything about Pelles C and it's standard libraries.