NO

Author Topic: Maze problem  (Read 2395 times)

00bob

  • Guest
Maze problem
« on: December 07, 2011, 11:52:45 PM »
    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

   
Code: [Select]
   
   
    #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

  • Guest
Re: Maze problem
« Reply #1 on: December 08, 2011, 01:20:07 AM »
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...
Code: [Select]
fopen("reamaze.dat","r");

We also explained about checking return values to be sure the file is opening...
Code: [Select]
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.
 


 
« Last Edit: December 08, 2011, 01:24:22 AM by CommonTater »