作者shmm (终於好了 ^^)
看板ESOE-91
标题计程第一题 +版
时间Thu May 29 00:46:59 2003
#include <stdio.h>
/* 要使用 fprintf() 须引入 stdio.h */
#include <conio.h>
/* 要使用 getche() 须引入 conio.h */
int main()
{
FILE *file;
file=fopen("data.txt","w");
/* 以上就是我们还没交的 */
char name[20],sexy,birthplace[80],step;
int age,i=0;
do{
printf("请依序输入第%2d笔资料.\n"
"姓名: ",++i);
gets(name);
printf("性别(男:m/女:f): ");
scanf("%c",&sexy);
printf("出生地: ");
getchar();
gets(birthplace);
printf("年龄: ");
scanf("%d",&age);
/* 输入资料 */
fprintf(file,"%2d\t姓名:%s\t性别:%c\t出生地:%s\t"
"年龄:%d\n",i,name,sexy,birthplace,age);
/* 将资料存入 data.txt 中 */
printf("\n请输入任意键输入下一笔资料或按[q]结束程式\n");
getchar();
step=getche();
/* 判断是否结束 */
} while(step!='q');
printf("\n谢谢您的使用\n"
"程式结束!!!\n");
fprintf(file,"\nDone");
return 0;
}
--
※ 发信站: 批踢踢实业坊(ptt.csie.ntu.edu.tw)
◆ From: 140.112.240.76
※ 编辑: shmm 来自: 140.112.240.76 (05/29 00:47)