函数listLength((在此范围内未根据编译器声明。但是它在main((函数之前都声明。
即使我查看了别人的问题,我也不会看到该功能没有错。
代码怎么了?
/* ... */
int listLenght(node* head){
node *temp = head;
int length;
while(temp->next != NULL){
length++;
temp = temp->next;
}
return length/2;
}
void createList(int length, node *head){
node *temp = head;
for(int i = 0; i < length; i++){
temp->next = (node*) malloc(sizeof(node));
temp->data = i;
temp = temp->next;
temp->next = NULL;
}
}
...
int main(){
node *head = (node*) malloc(sizeof(node));
createList(5, head);
int a = listLength(head);
}
listLength()
未定义。
listLenght()
是。
首先相信编译器或试图证明这是错误的。
,发现这种小错误很容易。
IE。搜索" ListLength",并看到它在您的代码内部...除了呼叫以外的任何地方,编译器都在抱怨。
或(马丁·詹姆斯(Martin James(的不错的输入(,另一方面,采用编译器抱怨的"未定义符号",并将其粘贴在"显然是相同"定义的地方。"令人惊讶的是,清除问题的频率"(马丁和我完全同意(。如果确实有帮助,那么很难看到(甚至三次(差异。
'1'(数字(,
'l'(小写'l'(,
'i'(大写'i'(
在某些字体中可能非常相似。