for our final semester project, in operating systems class has been tasked implementing pseudo "linux filesystem". idea simulate handling files, folders, changing directories, , forth.
i dislike having work strings , pointers when program in c, , unfortunately peace-of-mind, project looks involve both. because relatively uncomfortable pointers, hoping sanity check backend implementation of underlying tree structure sound.
typedef struct floornode { char floorname[30]; //the name of tree node struct floornode *parentpointer; //this pointer parent node. null root node. struct floornode *childpointers[10]; //this array holding pointers 10 child nodes. char filearray[10][30]; //this array of 10 'files', each of length 30. //for assignment, strings type of "file" } floornode;
is proper way implement tree in c?
that more or less proper data type.
i'm concerned filearray[][]
. don't think needed, unless i'm misunderstanding purpose. floorname
of children, instead traverse childpointers[]
obtain name in children.
something consider if nodes have 30 character strings make storage of them little bigger, 31 in case, trailing nul present , no special yucky handling needed distinguish between 30-character string without nul , shorter strings have one.
Comments
Post a Comment