错误C3861:'initNode':标识符找不到

编程入门 行业动态 更新时间:2024-10-22 12:32:35
本文介绍了错误C3861:'initNode':标识符找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到以下编译错误:

错误C3861:'initNode':标识符找不到

error C3861: 'initNode': identifier not found"

下面是code:

# include <conio.h> # include "stdafx.h" # include <stdlib.h> struct node{ node * next; int nodeValue; }; node*createList (int value) /*Creates a Linked-List*/ { node *dummy_node = (node*) malloc(sizeof (node)); dummy_node->next=NULL; dummy_node->nodeValue = value; return dummy_node; } void addFront (node *head, int num ) /*Adds node to the front of Linked-List*/ { node*newNode = initNode(num); newNode->next = NULL; head->next=newNode; newNode->nodeValue=num; } void deleteFront(node*num) /*Deletes the value of the node from the front*/ { node*temp1=num->next; if (temp1== NULL) { printf("List is EMPTY!!!!"); } else { num->next=temp1->next; free(temp1); } } void destroyList(node *list) /*Frees the linked list*/ { node*temp; while (list->next!= NULL) { temp=list; list=temp->next; free(temp); } free(list); } int getValue(node *list) /*Returns the value of the list*/ { return((list->next)->nodeValue); } void printList(node *list) /*Prints the Linked-List*/ { node*currentPosition; for (currentPosition=list->next; currentPosition->next!=NULL; currentPosition=currentPosition->next) {`enter code here` printf("%d \n",currentPosition->nodeValue); } printf("%d \n",currentPosition->nodeValue); } node*initNode(int number) /*Creates a node*/ { node*newNode=(node*) malloc(sizeof (node)); newNode->nodeValue=number; newNode->next=NULL; return(newNode); }

如何解决这个问题?

How to fix this error ?

推荐答案

错误发生,因为 initNode()它被调用之前是不可见的。要纠正地方 initNode的声明(),或它的首次使用前移到它的​​定义,以

The error is occurring because initNode() is not visible before it is called. To correct place a declaration for initNode(), or move its definition, to before its first use.

在code看起来像C,但它似乎使用的是C ++编译器来编译它(如使用节点而不是结构节点似乎不是导致编译失败,除非你没有报告在您的文章,这些错误)。如果您使用的C编译器(可通过其与Visual Studio的源文件中的 .C 扩展可以轻松实现),你并不需要转换的返回值的malloc()。间看到不兼容性ISO C和ISO C ++ ,一发现提供了问题的答案What问题可能我预计编译C code与C ++编译器?

The code looks like C but it appears you are using a C++ compiler to compile it (as use of node and not struct node appears to not be causing the compiler to fail, unless you have not reported these errors in your post). If you use a C compiler (which can be easily achieved by having a .c extension on your source file with Visual Studio), you do not need to cast the return value of malloc(). See Incompatibilities Between ISO C and ISO C++ , a link a found provided on answer to the question What issues can I expect compiling C code with a C++ compiler?

更多推荐

错误C3861:'initNode':标识符找不到

本文发布于:2023-10-07 15:22:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469759.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识符   找不到   错误   initNode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!