realpath.c 546 B

12345678910111213141516171819202122232425262728293031
  1. #include <errno.h>
  2. #include <limits.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "test_helpers.h"
  7. int main(void) {
  8. char* path = realpath("stdlib/realpath.c", NULL);
  9. if (!path) {
  10. perror("realpath");
  11. exit(EXIT_FAILURE);
  12. }
  13. puts(path);
  14. free(path);
  15. path = malloc(PATH_MAX);
  16. memset(path, 0, PATH_MAX);
  17. realpath("stdlib/realpath.c", path);
  18. if (!path) {
  19. perror("realpath");
  20. free(path);
  21. exit(EXIT_FAILURE);
  22. }
  23. puts(path);
  24. free(path);
  25. }