getcwd.c 957 B

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