冰楓論壇

標題: 查學號姓名的要如何寫呢 [打印本頁]

作者: 匿名    時間: 2016-5-11 22:07
標題: 查學號姓名的要如何寫呢
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{

   int sid; FILE *fp;
   char no[20],name[20],*pch,find[20],type=1;

   fp=fopen("abc.txt","r");   這部分是學號姓名的txt檔  我有放在與這專案檔放在一起
   printf("輸入1查學號  輸入2查姓名 " ) ;
   scanf("%s, ",find);

請問這裡要怎麼打輸入1就能查學號
輸入2就能查姓名


打完1 打學號其中2碼  就會把所有學號有那2碼的都找出來
打完2 打姓氏就能把她找出來 (ex:陳    這樣就把所有姓陳的都列出來)


    do
{   

     type;
}

   while(type>2);
   if(type==1)
   printf(no,find);
   else
   printf(name,find);
   do
{
    fscanf(fp,"%s %s",no,name);
    pch=strstr(no,find);
    if ( pch !=NULL)
    printf("%s %s\n",no,name);
}
   while(!feof(fp));

   fclose(fp);
   system("PAUSE");
   return 0;
}



請會的幫忙想想看唷

我是可以執行  但是只差  中間紅色那塊部分 不知道怎麼弄出來






歡迎光臨 冰楓論壇 (https://bingfong.com/) Powered by 冰楓