#include<stdio.h>
#include<stdlib.h>
int main(){
FILE *fptr;
char ch;
fptr=fopen("character.dat","w");
printf("請輸入一字元: ");
scanf("%c",&ch);
while(getchar()!='\n'){continue;}
while(ch!='*'){
fprintf(fptr,"%c",ch);
printf("請輸入一字元: ");
scanf("%c",&ch);
while(getchar()!='\n'){continue;}
}
fclose(fptr);
fptr=fopen("character.dat","r");
printf("\n以下是你輸入的data:\n");
/*ch=fgetc(fptr);
while(ch!=EOF){
printf("%3c\n",ch);
ch=fgetc(fptr);
}
*/
while(fscanf(fptr,"%c",&ch)!=EOF){
printf("%3c\n",ch);
}
fclose(fptr);
system("pause");
return 0;
}
沒有留言:
張貼留言