Hello, Im using fscanf() for file reading, but how do i get fopen() to look in the current directory for the file im loading? On my pocket pc it imediatly looks for the base dir. I tried typing in the whole path, but i suspect that a path with spaces in it messes the program up. I hope someone has run into this problem before......
To obtain the executable's pathname, use:
- Code:
...
TCHAR pathname[MAX_PATH];
GetModuleFileName( 0, pathname, MAX_PATH );
...
You then need to stripoff the executable's filename from "pathname" and replace it with the name of the file you want to open. You do this by searching for the last occurence of the '\' character (or is it '/'?)