Attendez-moi 指针数组与strcmp fgets等函数的配合使用

来源:互联网 发布:趣头条刷阅读量软件 编辑:程序博客网 时间:2024/06/03 10:10
#include <stdio.h>#include <string.h>#define LISTSIZE 5int main(int argc, char const *argv[]){  char * list[LISTSIZE] = {    "astronomy", "astounding",    "astrophysics", "osttracize",    "asterism"  };  int count = 0;  int i;   char m[5][10];//此处应用二维数组,本质为二级指针   fgets(*m, sizeof(m),stdin);    /* m应加*,二级指针,否则类型不匹配, 或m[5],     但不允许m[5][10]*/  for(i = 0; i< LISTSIZE; i++)  {   if(strcmp(list[i], m[3]))   {    printf("Found: %s\n", list[i]);    count++;   }  }   printf("The list contained %d words beginning\n", count); return 0;}
原创粉丝点击