错误 C3861:"initNode":找不到标识符
error C3861: 'initNode': identifier not found
我得到以下编译错误:
错误 C3861:"initNode":找不到标识符"
下面是代码:
# 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);
}
如何修复此错误?
发生错误是因为initNode()
在调用之前不可见。更正放置initNode()
声明,或将其定义移动到首次使用之前。
代码看起来像 C,但似乎您正在使用 C++ 编译器来编译它(因为使用 node
而不是 struct node
似乎不会导致编译器失败,除非您没有在帖子中报告这些错误)。如果使用 C 编译器(可以通过使用 Visual Studio 在源文件上使用.c
扩展名轻松实现),则不需要强制转换返回值 malloc()
。请参阅之间的不兼容性ISO C 和 ISO C++ ,在回答问题时提供了链接 使用 C++ 编译器编译 C 代码会遇到哪些问题?
相关文章:
- 设置 Visual Studio for MPI: 找不到标识符错误
- 找不到标识符合并
- 在 c++ 中找不到此函数的标识符
- 从子类访问模板类成员时出现"找不到标识符"错误
- std::p opcount 标识符在 MSVC 16.6.0 中找不到
- OpenCV 3 错误"CV_FOURCC":找不到标识符
- C++ ATL | 找不到_InternalQueryInterface标识符
- im调用函数时找不到标识符?
- clock_gettime:在 Windows 10 的 Visual Studio 中找不到标识符
- 英特尔 TBB - "初始化关键部分 Ex":找不到标识符编译器错误
- 找不到标识符.C3861
- 找不到睡眠标识符 Visual Studio 2017
- 在void tryagain()上找不到标识符
- 找不到内存集标识符
- 在C 类中找不到标识符
- 找不到标识符,尝试在 C++ 中显示数组值
- 找不到QT 5.6 update()函数标识符
- 我遇到:错误2错误C3861:"fx":找不到标识符
- 找不到加载着色器标识符
- OpenGL - 'glTexSubImage3D':找不到标识符