Result of function is “garbage” when getting current directory?
-
30-10-2019 - |
Question
Why does the following code, produce the following output?
UPDATING MY CODE TO THIS: i get basically the same thing.
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#define GetCurrentDir getcwd
#endif
//==============================MAIN=======================================
#ifdef _WIN32
int main(int argc, char **argv)
{
char *path = (char*)malloc(sizeof(char)*FILENAME_MAX);
GetCurrentDir(path, sizeof(path));
printf("path: %s\n", path);
//other stuff
}
//==============================END========================================
OUTPUT path : -
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow