Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// realpath.c: display the absolute path to a file or directory.
// Adam Liss, August, 2007
// This program is provided "as-is" to the public domain, without express or
// implied warranty, for any non-profit use, provided this notice is maintained.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <limits.h>
static char *s_pMyName;
void usage(void);
int main(int argc, char *argv[])
s_pMyName = strdup(basename(argv[0]));
if (argc < 2)
printf("%s\n", realpath(argv[1], sPath));
return 0;
void usage(void)
fprintf(stderr, "usage: %s PATH\n", s_pMyName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.