Skip to content

Instantly share code, notes, and snippets.

@noqisofon
Created December 14, 2016 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noqisofon/63b13a59d2f58d64a9f404d171c8db91 to your computer and use it in GitHub Desktop.
Save noqisofon/63b13a59d2f58d64a9f404d171c8db91 to your computer and use it in GitHub Desktop.
( ノ╹◡◡╹)ノ ファイルのサイズを取得するような感じ
#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