Hello!
How can I retrieve current dir (where my EXE is placed, like in vb App.Path)?
And which are alternatives of Left() and Right() VB function in VC++?
Printable View
Hello!
How can I retrieve current dir (where my EXE is placed, like in vb App.Path)?
And which are alternatives of Left() and Right() VB function in VC++?
When you start a console app (using main), argv[0] contains the full path and filename of your executable, for example c:\myprog\myprogram.exe.
To use equivalents of Left and Right, simply use strncpy in this way:
This code reproduces Left. To use Right, you'd have to count backwards from the end of the string.Code:char *pcSrc = "Hello World";
char *pcDest = new char[length+1];
strncpy(pcDest, pcSrc+offset, length);
pcDest[length] = 0; // Terminator
I'm developing a MFC app.
Is argv[0] the same in MFC as in console app or do I have to do something else?
You can use the GetCurrentDirectory function in Win32/MFC apps.
Code:TCHAR tcCurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH, tcCurDir);
// tcCurDir now contains the current directory.
// At least, it should be. :rolleyes: