Member Avatar


I would love to create in C/C++ an array in which each cell is a pointer on a linked list of integers: can someone tell me how can I implement this ?

Thank you very much for your help


If you're doing this in C++, you might want to think about a vector of lists, e.g.

#include <vector>
#include <list>

int main()
    std::vector< std::list<int> > lists;
    std::list<int> new_list;

    lists.push_back( new_list );

As for a 'C' implementation:
Do you know how to create an array of pointers?
Do you know how to implement a linked list?
If you can do both of those, then that's 95% of the work.

This link appears in the "similar threads" box - maybe worth a read:

Member Avatar

Thank you a lot Mr. Bench

If you wan't to learn about linked list, try implementing it. Give it a shot and
tells us how it goes, that is if your up for it.

Member Avatar

Yes, I know how to use simple linked lists in C.

Happy new year for you both.