#include <stdio.h> /* $Id: GetFileSize.html,v 1.1 2009/06/22 16:11:45 kishi Exp kishi $ */ int main (void) { FILE *fp; const char *filename = "GetFileSize.c"; size_t size; fp = fopen (filename, "r"); if (fp == NULL) { fprintf (stderr, "cannot open %s\n", filename); return -1; } fseek (fp, 0L, SEEK_END); // ファイルポインタを最後尾へ移動 size = ftell (fp); // ファイルサイズを取得 fseek (fp, 0L, SEEK_SET); // ファイルポインタを先頭へ移動 fclose (fp); printf ("ファイルサイズは、%d です。", size); return 0; }戻る