강좌 & 팁
글 수 2,412
2012.11.22 20:04:57 (*.52.177.29)
72504
gcc를 이용하여 파일 크기를 구하는 방법입니다.
seek()를 이용하는 것보다 훨씬 간단하지요? ^^
*** P.S. : 구글 크롬에서는 소스가 잘 안 보일 수 있습니다.
IE나 다른 웹 브라우저를 이용하세요.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
int main( void){
struct stat file_info;
if ( 0 > stat( "./test.c", &file_info))
printf( "파일이 없습니다.\n");
else
printf( "파일 크기는 =%d\n", file_info.st_size);
return 0;
}


