【发布时间】:2011-06-08 05:50:48
【问题描述】:
我写了一个结构
struct Tree{
struct Node *root;
struct Node NIL_t;
struct Node * const NIL; //sentinel
}
我想要
struct Node * const NIL = &NIL_t;
我无法在结构中初始化它。 我正在使用 msvs。
我使用 C,而不是 C++。 我知道我可以在 C++ 中使用初始化列表。
如何在 C 中做到这一点?
【问题讨论】:
-
出于好奇,为什么需要 NIL_t 的值和指向 NIL 的指针?这似乎有点多余。独立地,这是一个有趣的问题!
-
正确。你没有使用 C++,这就是你不能这样做的原因。
标签: c struct initialization constants