Not sure if uni work's assistance is allowed here, pls advise me if itsnt. Anyway, Im studying C and atm, I have problem dealing with file input/output. Have been trying hard to work out, but no luck so far

Im thinking about struct and array, but not sure if its the right method. Also, I have no idea how to read the file and write to memory with such format.

There is no single right answer. Everything in programming is a compromise attempting to balance corporate bureaucracy, hardware constraints, time constraints, & considering the poor slob who gets to inherit your code once you leave the project or company.

That said, the format described dictates an easy representation:

The first character read names the node itself.

The next value read defines the number of dependencies/adjacencies...

...followed by an enumeration of all the dependencies'/adjacencies' names.

The question ultimately becomes how to represent the variable list of names. If you know the upper bound of how many dependencies/adjacencies to expect, then you can use an array, however as a precaution, I would recommend you implement the error logic needed to ensure that the array bounds are not exceeded.

If this is how you implement the solution, you will need to a structure which:

stores the node's name.

stores the number of dependencies/adjacencies.

stores the names of all dependencies/adjacencies in an array.

A better solution would be to implement a linked list which gets away from the constraints of an array. This approach simplifies what needs to be stored given that the linked list is only restricted by available heapspace:

Again, store the node's name.

Store the names of all dependencies/adjacencies in a linked list.

Maintaining the number of dependencies/adjacencies is optional.

Perhaps you haven't gotten into dynamic memory allocation yet in your studies. If not, then the second approach is not an option.

So, this only defines a single record. Either you know the maximum number of records to expect, or you don't. If you do, then you can create an array of records, but you will also require an external index counting how many records have been read thus far. This describes one approach.

Again, a better approach is to create a linked list of records for the same reasons as before. Yes, this means managing nested linked lists, but if you test incrementally as you write the code, this won't be as daunted as it may appear.