Created
December 14, 2016 07:49
-
-
Save noqisofon/63b13a59d2f58d64a9f404d171c8db91 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 <unistd.h> | |
#include <stdio.h> | |
off_t get_file_size(const char* filename) { | |
struct stat file_status; | |
stat( filename, &file_status ); | |
return file_status.st_size; | |
} | |
int main() { | |
off_t file_size = get_file_size( "/etc/hostname" ); | |
printf( "%d\n", file_size ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment