#include <stdio.h>
void rewind(FILE *stream);
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE *fp;
char *str1 = "hello";
char *str2 = "linux";
char buf[32];
bzero (buf, sizeof(buf));
fp = fopen("test.txt", "w+");
fprintf (fp, "%s %s", str1, str2);
fseek(fp, -strlen(str2), SEEK_CUR);
fscanf (fp, "%s", buf);
printf ("%s\n", buf);
rewind(fp);
fscanf (fp, "%s", buf);
printf ("%s\n", buf);
return 0;
}
$ ./rewind
linux
hello
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |