#include <stdio.h>
#include <string.h>
#define LISTSIZE 5
int 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;
}
Attendez-moi 指针数组与strcmp fgets等函数的配合使用
最新推荐文章于 2023-10-31 11:24:33 发布
