Hello,

So my problem is that I am supposed to write code in order to prove whether or not text in a file is topologically sorted correctly.
I have the algorithm on how to do this, but the specifications say that I should use an array of lists to keep track of each element's successors.
The thing is, I have no idea how to even start this.
I know how to declare an array of like ints, but not of lists.
Could I have some help?

Thanks

Edited 6 Years Ago by fattymuffin: never mind, i am just going to do it another way, thanks

Hello,
I know how to declare an array of like ints, but not of lists.
Thanks

One way to do this is to create an array of pointers to arrays (lists)

The following code will create an array of pointers to arrays of unsigned ints, just replace the unsigned int part with whatever datatype your list contains:

unsigned int ** ProtocolReceiveBuffer;
int rows = 2;
int cols0 = 1500;
int cols1 = 1500;

ProtocolReceiveBuffer = malloc((rows)*sizeof(unsigned int*));

ProtocolReceiveBuffer[0] = malloc((cols0)*sizeof(unsigned int));
ProtocolReceiveBuffer[1] = malloc((cols1)*sizeof(unsigned int));
This question has already been answered. Start a new discussion instead.