Ex3.
#include <stdio.h>
#include <string.h>
#include <process.h>
int main ()
{
FILE *fp;
char a[80],b[80];
int i,j,temp;
fp=fopen("data.txt","r");
do {
printf ("輸入欲查詢之人名\n");
scanf ("%s",b);
for (i=0;i<20;i++) {
fscanf (fp,"%s",a);
if ( strcmp(b,a)==0 ) {
printf ("%s",a);
for (j=0;j<4;j++) {
fscanf (fp,"%s",a);
printf ("%s",a);
}
exit (1);
}
}
printf ("查無此人,請重新輸入\n");
temp=1;
fclose (fp);
fp=fopen("data.txt","r");
}
while (temp==1);
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.26.82