The "current directory" is whatever directory the program is run from on the commandline. When you double-click on an exe to run it in Windows Explorer, this puts the current directory as the exe directory.
It is usually be safe to assume that the current directory will be the exe directory at startup. Many programs expect to run that way, and if you don't run them that way they will usually have lots of failures at startup.
The big exception is when you run a program from an IDE's debugger. For some reason (which I never understood), IDEs like to launch the program from a directory other than the exe directory. Which leads to the troubles you're having.
As for solutions:
1: Change your project settings in your IDE so that it launches the debugger from the exe directory. I have no idea how to do this in Eclipse since I never use it, but I'm sure it can be done.
2: When developing, move all of your necessary files to the current directory, rather than putting them in the exe directory. When you release the game, you can throw all the files back in the exe directory (remember that when you run from explorer, the exe directory will be the current directory -- the problem is only when you run it from the IDE, which users won't be doing)
3: Put code in your program so that it looks for files in the exe directory, rather than the current directory.
I don't recommend this approach at all since it might conflict with what your users want or expect, is non-portable, and is unnecessary additional code.
On Windows there are 3 functions which help with this:
1) GetCurrentDirectory
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364934%28v=vs.85%29.aspx
2) SetCurrentDirectory
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365530%28v=vs.85%29.aspx
3) GetModuleFileName
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx
GetModuleFileName gives you the exe directory if you give it NULL for the module handle.
Note that all 3 are Windows only and are nonportable. And again you shouldn't
really need these because running from the current directory is pretty normal behavior for all programs (hence why the concept of a current directory exists)
--------------------------------------
When using directories in code:
-
Prefer '/' over '\\'. '/' works on Windows and pretty much everything else. '\\' works only on Windows and on nothing else. Also '/' tends to be less error prone because \ is the escape character.
-
Do not start directories with a '/' character. If you try to open "/path/file", on Unix, that looks in the root directory which is not relative to the current directory. If you want to look in a directory that's in the current directory, use "path/file".