working-directory.c 308 B

123456789101112131415161718192021
  1. #include <stdio.h>
  2. #if defined(_WIN32)
  3. #include <direct.h>
  4. #define getcwd _getcwd
  5. #else
  6. #include <unistd.h>
  7. #endif
  8. int main()
  9. {
  10. char working_directory[8096];
  11. if (getcwd(working_directory, sizeof(working_directory)) == NULL) {
  12. return 1;
  13. }
  14. printf("%s", working_directory);
  15. return 0;
  16. }