#include<stdio.h>
#include<stdlib.h>
int main(){
char name[20];
int score;
FILE *fptr;
fptr=fopen("score.dat","w");
printf("請輸入學生姓名:");scanf("%s",name);
printf("請輸入學生分數:");scanf("%d",&score);
while(score>=0){
fprintf(fptr,"%s %d",name,score);
printf("請輸入學生姓名:");scanf("%s",name);
printf("請輸入學生分數:");scanf("%d",&score);
}
fclose(fptr);
return 0;
}
沒有留言:
張貼留言