Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
( ノ╹◡◡╹)ノ ファイルのサイズを取得するような感じ
#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