Hi,
I am having a problem with fopen. I have searched the forum but with no luck.
i am trying to open a binary file using fopen. I am using Borland C++ 3.1 and it cannot open the file. fopen gives a NULL pointer. When opening the same program in Turbo C++ for Windows it seems to work correctly.
the file is stored in the follow location
J:\dsaaIII\ass1\Program 3\DATABASE.BIN
This is my code
The above is a code snippet. The actual fuction is more complex. however it should still be able to open the file. which it is clearly failing.Code:char fname[]="J:\\dsaaIII\\ass1\\Program 3\\DATABASE.BIN"; FILE * ptrFile; ptrFile=fopen(fname, "rt"); if(ptrFile==NULL){ printf("\n Error Opening Database File!\n\n Please Press Any Key To Continue >"); getch(); clrscr(); return 0; } fread( lastRecordID, sizeof(int), 1, ptrFile ); fclose(ptrFile);
Thanks in advance.
Chris



LinkBack URL
About LinkBacks


