看板 ESOE-90 關於我們 聯絡資訊
#include<stdio.h> #include<process.h> int main() { FILE *x; int i,j; char a[50],b[80]; x=fopen("test.txt","r"); for(i=0;i<20;) { printf("輸入你要查詢的名字\n"); scanf("%s",a); for(j=0;j<5;j++) { fscanf(x,"%s",b); if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]) { printf("%s\n",b); exit(1); } } printf("無此人請重新輸入\n"); fclose(x); x=fopen("test.txt","r"); } fclose(x); return 0; } ---------------- test.txt sky-man-tp-19 bala-man-hk-21 bass-man-tp-19 yaw-man-tp-19 acho-man-tp-19 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.99.213