Created
February 15, 2014 20:14
-
-
Save sguzman/9024663 to your computer and use it in GitHub Desktop.
Got the idea from https://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/stat.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) | |
{ | |
return 0; | |
} | |
struct stat buffer; | |
if (stat(argv[1], &buffer) == 0) | |
{ | |
printf("Yes.\n"); | |
} | |
else | |
{ | |
printf("No.\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now if only it were built-in, it could actually beat ls ...