|
-
Dec 8th, 2002, 12:01 AM
#1
Thread Starter
Hyperactive Member
Can't FOPEN in Turbo C?
I have installed turbo c into C:\TC, and created a Work folder in that, so I have C:\TC\Work\test.c
In test.c, a portion of it is:
Code:
FILE *file;
file = fopen("maze.txt", "rb");
if (file == NULL) {
printf("Error: Could not open file");
}
I get a could not open file, but maze.txt is in C:\TC\Work... I've also tried just putting it into C:\TC, yet it still does not seem to work. I've also tried Going Alt+O->Directories->Setting to C:\TC\Work.
Any help is VERY MUCH appreciated!
-
Dec 11th, 2002, 11:34 AM
#2
Junior Member
Reply
Is that where the exe is compiled? try putting it in the debug folder (if it has one), I only have experience with using VC++ as an IDE
Chris
-
Dec 11th, 2002, 12:11 PM
#3
Frenzied Member
Code:
FILE *file;
file = fopen("c:\\tc\\maze.txt", "rb");
if (file == NULL) {
printf("Error: Could not open file");
}
You have to explicitly specify the path, if the code runs in a different path. Always having a path specifier as part of the filename is the best approach. That way you can be sure of which file you are opening. It's not uncommon for files in other paths to have identical names.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|