2010年10月24日 星期日

檔案大小

-----
[知道檔名]
struct stat statbuf;
int filesize;
stat("copyfile1.txt", &statbuf);
filesize=statbuf.st_size; // bytes
printf("File size=%d bytes\n", filesize);


-----
[FILE *]
long filesize;
fseek(fp, 0L, SEEK_END); //移動到相對END的0L位置 filesize=ftell(fp); //傳回相對開始位置的bytes數 fseek(fp, 0L, SEEK_SET); //移動到絕對位置0L的位置

----
[ps]
fopen(); // If failed, return NULL
open(); // If failed, return -1

沒有留言:

張貼留言