Fopen mysteriously under Windows

Maybe I just have one more black color, but this one line gives me a lot of trouble:

FILE *fp = fopen("data/world.data", "rb");

This works fine under Linux when compiling with GCC. But when I compile it with Visual Studio, it will work. fp always NULL. Both BIN and EXE are in the same directory. Now, to make things even crazier when I run EXE using Wine under Linux ... it ... works ...

I have absolutely no damn thing going on here. Perhaps this is some insanely stupid mistake on my side, but I can not get this thing to work under Windows: /

In addition, I have another program that works very well, there the data files are also contained in the data subdirectory.

EDIT :
To clarify, / NOR `\ * does not work .

EDIT 2:
Well, I gave it up, maybe someone had some fun trying to figure it out, here's a ZIP containing EXE, Debug Data for VS, etc:
https://dl.dropbox.com/u/ 2332843 / Leaf.zip

EDIT 3:
Compiled with CodeBlocks and MinGW, it works like a charm. Guess it has to do something with MSVC or Project settings in VS.

+3
source share
7 answers

, data . ( x86) VS DEBUG RELEASE , . , "" (, | | | VS 2008).

. Windows , , - .

+6

:

FILE *fp = fopen("data\\world.data", "rb");

, ( \ \", ).

+2

Windows. , "world.data". , . world.data.xxx?

+1

GetCurrentDirectory(), , .

#/++ visual studio, . , , .net .

0

, .

Windows.

, FILE *fp = fopen("data/world.data", "rb"); , , /world.data, /data/world.dat.txt .

, .

, !

0

, , "br" "rb" mode.

fopen , . NULL .

0

, , (?)?

-1

Source: https://habr.com/ru/post/1755195/


All Articles