Native/C
[posix] 파일 정보 얻기 (사이즈,size, 상태 stat, file)
aucd29
2013. 10. 2. 18:52
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
int main()
{
struct stat buf;
int ret;
ret = stat("test.c", &buf);
if ( ret != 0 ) {
perror("stat()");
exit(errno);
}
printf("len = %ld\n", buf.st_size);
return 0;
}
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
int main()
{
struct stat buf;
int ret;
ret = stat("test.c", &buf);
if ( ret != 0 ) {
perror("stat()");
exit(errno);
}
printf("len = %ld\n", buf.st_size);
return 0;
}