C file input/output: Difference between revisions

Content deleted Content added
adding file stdio.h and link
Dkasak (talk | contribs)
Corrected the code snippet.
Line 36:
 
A convenient, but non-standard, way to find the length of a file in C is:
<pre>
#include <stdio.h>
int main(void) {
{
int length;
FILE *f = fopen("filename", "r");
fseek(f, 0L, SEEK_END);
length = ftell(f);
rewind(f);
fclose(f);
printf("%d\n", length);
return 0;
}
</pre>
 
==See also==