Differences between current version and predecessor to the previous major change of realpath.c.

Other diffs: Previous Revision, Previous Author

Newer page: version 2 Last edited on Tuesday, 20 October 2009 8:23:30 by CyberLeo
Older page: version 1 Last edited on Tuesday, 22 January 2008 15:20:26 by CyberLeo Revert
@@ -1,5 +1,5 @@
-<verbatim
+<code brush="c"
 #include <stdio.h> 
 #include <limits.h> 
 #include <stdlib.h> 
 #include <errno.h> 
@@ -20,5 +20,5 @@
 
 
  return 255; 
 
-</verbatim
+</code

current version

#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>

int main (int argc, char **argv) {
        char resolved_path[PATH_MAX];
        if (argc != 2) {
                printf("Usage: realpath <path>\n");
                return 1;
        } else {
                if(realpath(argv[1], resolved_path) != NULL) {
                        printf("%s\n", resolved_path);
                        return 0;
                }
                if (errno) {
                        fprintf(stderr, "realpath: %s: %s\n", argv[1], strerror(errno));
                        return errno;
                }
        }
        return 255;
}