getcwd.c 848 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fork test for uClibc
  4. * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. int main(void)
  12. {
  13. char *foo;
  14. char junk[12];
  15. char crap[100];
  16. foo = getcwd(NULL, 0);
  17. printf("getcwd(NULL, 0)='%s'\n", foo);
  18. if (foo) { free(foo); }
  19. foo = getcwd(NULL, 100);
  20. printf("\ngetcwd(NULL, 100)='%s'\n", foo);
  21. if (foo) { free(foo); }
  22. foo = getcwd(junk, sizeof(junk));
  23. printf("\nchar junk[12];\n");
  24. printf("getcwd(junk, sizeof(junk))='%s'\n", foo);
  25. foo = getcwd(crap, sizeof(crap));
  26. printf("\nchar crap[100];\n");
  27. printf("getcwd(crap, sizeof(crap))='%s'\n", foo);
  28. return EXIT_SUCCESS;
  29. }
  30. /*
  31. Local Variables:
  32. c-file-style: "linux"
  33. c-basic-offset: 4
  34. tab-width: 4
  35. End:
  36. */