我知道在编程中保持简单并且能够被改变是很重要的。所以对我来说,这意味着使用不同的文件和函数并将它们分开以更容易隔离错误并提高可读性非常重要。
我是 C 新手,我不明白如何做到这一点。我有我的 nodeTest.h
#include <stdio.h>
#include <stdlib.h>
struct nodeTest
{
int data;
struct nodeTest* next;
};
然后我有另一个文件试图调用该结构
#include <stdio.h>
#include <stdlib.h>
#include "nodeTest.h"
nodeTest* first = (nodeTest*)malloc(sizeof(nodeTest));
我收到一条错误消息,指出 nodeTest 未声明(不在函数中)。这是什么意思,为什么我不能使用 include 来包含结构或 typedef?