0
votes

I'm having trouble opening a file for reading, but only when it is inside a folder. I'm using Visual Studio 2010, and placing the folders with the files inside the "Debug" folder with the .exe, and running it just by clicking the .exe (not from within VS). The code that is failing to work is:

FILE* FileHandle = fopen("./maps/1.area", "r");

if(FileHandle == NULL) {
    return false;
}

FileHandle is always coming up as NULL. The code works fine if I move 1.area to the same folder as the exe, but if I move it down a level, it doesn't work. This same filepath style works when I use an SDL method to open a bitmap, so I can't figure out why it's failing with fopen.

1
backslashes vs. slashes? - phonetagger
Is your directory "maps" existing? - Kirill Kobelev
Yes, /maps exists, and I've tried both backslashes (properly escaped) and forward slashes. - rkevingibson

1 Answers

0
votes

Yeah, buddy, I'm goin' with this: fopen() is part of the C standard library, not the "SDL standard library". Though SDL may be permissive with slash styles, I'm betting fopen() is not.