#include <stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
printf("请输入一个字符串:");
char str[30];
scanf("%s",str);
FILE *fp = NULL;
fp = fopen("ax.txt","w");
int i;
if(fp != NULL ){
for(i = 0;i < strlen(str);++i){
fputc(str[i],fp);
}
printf("输入字符串成功!!!\n");
rewind(fp);
char s = fgetc(fp);
printf("%c",s);
while(s != EOF){
printf("输入字符串成功!!!\n");
putchar(s);
s = fgetc(fp);
}
}
fclose(fp);
return 0;
}
求指教 |
|