【发布时间】:2012-11-21 20:28:06
【问题描述】:
我被一些没有评分的家庭作业困住了(它意味着练习)。
我必须创建一个名为find_name 的函数,它需要两个参数。第一个参数是一个二维的名字(字符串)数组,第二个是一个字符串,用于在二维数组中查找名字,如果找到则函数必须返回1,否则返回0。
当我调用函数(现在是空的)时,我得到了这个warning: passing argument 1 of 'find_name' from incompatible pointer type
这是重要的部分。
在主目录中
char strNameList[][2] = { { "Luca","Daniel"} ,{"Vivan","Desmond"},{"Abdul","Justin"}, {"Nina","Marlene"},{"Donny","Kathlene"} };
char strFindName[] = "\0";
printf("Please enter a name to look for: ");
gets(strFindName);
nSearch = find_name(strNameList, strFindName);
函数
int find_name(char strNameList[][2], char strLookUp[])
我是 C 新手(我是一名学生),我对字符串(字符串数组等)完全感到困惑。
【问题讨论】:
-
你想声明什么
char * strNameList[][2]或char strNameList[][2]? -
哎呀我有 char strNameList,而不是 char *strNameList