#include <stdio.h>
long ftell(FILE *stream);
#include <stdio.h>
#define NUM_ALPHA 26
#define NUM_CHAR 6
int main(void)
{
FILE *stream;
int i;
char ch;
char buffer[NUM_ALPHA];
long position;
if (( stream = fopen("test.file", "r")) != NULL) {
for (i = 0; (i < NUM_ALPHA/2) && ((buffer = fgetc(stream)) != EOF); ++i)
if (i == NUM_CHAR-1)
position = ftell(stream);
buffer = '\0';
}
printf ("Current file position is %d\n", position);
printf ("Buffer cantains: %s\n", buffer);
return 0;
}
[beyes@beyes files]$ ./ftell
Current file position is 6
Buffer cantains: abcdefghijklm
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |