如何在二维字符串数组中搜索整个单词。此代码仅输出我输入的单词的第一个字母。
谁能帮我这个 ?
该索引是如何在函数中传递的,只是我从这个搜索中找到的索引。
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#define PEOPLE 4
#define LEN_NAME 30
int main (void)
{
int i;
char found_name;
char name[PEOPLE][LEN_NAME]= {"John Lucas","Armanod Jonas",
"Jack Richard","Donovan Truck"};
printf("What name do you want to search?\n>");
scanf("\n%s", &found_name);
for (i = 0 ; i < PEOPLE; i ++)
{
if (strchr(name[i], found_name ) != NULL)
{
printf( "Found %c in position %d,%s\n", found_name, i+1, name[i]);
printf( " index of player is %d.\n",i +1);
}
}
return 0;
}