#include #include #include const char *str="This is some test data. This is some test data"; static void make_file(void) { FILE *f=fopen("test.file", "w"); fprintf(f, "%s", str); fclose(f); } static void test_file(void) { FILE *f=fopen("test.file", "a"); long int flen=ftell(f); if (flen == strlen(str) ) { printf("TEST PASSED: ftell gives: %ld\n", ftell(f)); } else { printf("TEST FAILED: ftell gives: %ld, strlen=%ld\n", ftell(f), strlen(str)); } } int main(void) { make_file(); test_file(); return 0; }