I'm using the Cygwin gcc compiler to compile and test a C program using Code::Blocks. I have a problem with the output of the "getcwd" function (unistd.h):
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
char workingDir[PATH_MAX];
if (getcwd(workingDir, sizeof(workingDir)) != NULL) {
fprintf(stdout, "Working directory: %s\n", workingDir);
}
}
When running in Code::Blocks, the getcwd function returns a full Cygwin path:
C:\Users\mrosh\CodeBlocks\GetcwdTest\bin\Debug\GetcwdTest.exe
Working directory: /cygdrive/c/Users/mrosh/GetcwdTest/GetcwdTest/bin/Debug
When running from the Windows command line, I only get the current working folder:
C:\Users\mrosh\CodeBlocks\GetcwdTest\bin\Debug>GetcwdTest.exe
Working directory: /Debug
I really need access to the full path from within my program, while running from the Windows command line. Any idea how I achieve that?