Anyone know how to in c determine the size of a file in bits? or bytes?
Printable View
Anyone know how to in c determine the size of a file in bits? or bytes?
Nevermind, have it figured, just got to use stat...
follow this code
long fsize(char * filename)
{
FILE *fp;
long lSize;
char c;
fp = fopen(filename, "r");
for(lSize = 0;(c = fgetc(fp)) != EOF; lSize++)
;
fclose(fp);
return ( lSize );
}
could also use
_filelength(handle of file)
this will return the number of bytes the file is.