2
0

getcwd.c 420 B

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