我们操作系统课程的最终学期项目要求每个人都实现一个伪“Linux文件系统”。目的是模拟处理文件、文件夹、更改目录等操作。
我不喜欢在C语言编程时使用字符串和指针,令我不安的是,这个项目似乎需要两者皆用。由于我对指针相对陌生,因此希望能得到一个内部树状结构的后端实现是否正确的审查。
typedef struct floorNode
{
char floorName[30]; //the name of the tree node
struct floorNode *parentPointer; //this is a pointer to the parent node. Null for the root node.
struct floorNode *childPointers[10]; //this is an array holding pointers to up to 10 child nodes.
char fileArray[10][30]; //this is an array of 10 'files', each of up to length 30.
//for this assignment, strings are the only type of "file"
} floorNode;
这是在C语言中实现树的正确方式吗?