Last active
August 29, 2015 14:01
-
-
Save sriramster/1e82fa266e683d3acf42 to your computer and use it in GitHub Desktop.
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/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#define usage() {printf("\n Usage %s file_name", argv[0]);} | |
int main(int argc, char *argv[]) | |
{ | |
if (argc < 2) { | |
usage(); | |
exit(-1); | |
} | |
int fd = open(argv[1], O_RDONLY); | |
struct stat buf; | |
if(fd < 0) { | |
perror("open error"); | |
exit(-1); | |
} | |
if(fstat(fd, &buf) < 0) { | |
perror("stat error"); | |
exit(-1); | |
} | |
printf("\n Size %ld", (long)buf.st_size); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment