Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在目录树(在 C 中)中,我试图通过“dir”结构()中的双指针将父目录连接到它们的子目录,struct dir **children但我不知道如何在语法上实际关联它们,或者“point给他们。” 一个代码示例会很棒!
struct dir **children
谢谢
struct dir **children不是“双指针”。它是一个指向指针的指针。
为了做你想做的事,你需要声明struct dir *children[5]5 是你想要指向的孩子的数量,或者如果你想让它是动态的,分配它struct dir **children = malloc(number_of_child * sizeof(*children));
struct dir *children[5]
struct dir **children = malloc(number_of_child * sizeof(*children));
然后,只需分配children[0] = childchild 所在的位置struct dir *
children[0] = child
struct dir *