getcwd.c 371 B

12345678910111213141516171819202122
  1. #include <limits.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. int main() {
  7. char first[PATH_MAX];
  8. getcwd(first, PATH_MAX);
  9. puts(first);
  10. char* second = getcwd(NULL, 0);
  11. puts(second);
  12. if (strcmp(first, second)) {
  13. puts("Not matching");
  14. free(second);
  15. return 1;
  16. }
  17. free(second);
  18. }