문제

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