質問

I want to use a if statement to check if a file size is greater than a determined number in kb. For example:

if(filesize GTREATER than VARX){
 DO
}else{
 DO
}

I'm new to C yet, so please, can you explain clearly, if I have to use a different function.

役に立ちましたか?

解決

If you've already fopen()ed the file, then you can use fstat(). stat() or lstat() can be used on files by name (in a string), but are somewhat less efficient if you do it repeatedly. You'll need to use fileno() to get the file descriptor (int) from the FILE * returned by fopen(). Otherwise, the man pages have reasonable examples.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top