兩種方法~

1.利用fseek(或lseek)

FILE* f = fopen(fileName, "r+");
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);

2.用stat函式

struct stat st;
stat(fileName, &st);
size = st.st_size;

 

參考網址:

http://stackoverflow.com/questions/238603/how-can-i-get-a-files-size-in-c

 

arrow
arrow
    文章標籤
    c
    全站熱搜

    卡卡 發表在 痞客邦 留言(0) 人氣()