Member Avatar for begueradj

Hello,

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

Begueradj

Recommended Answers

All 4 Replies

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;
    new_list.push_back(1);
    new_list.push_back(2);

    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:
http://www.daniweb.com/forums/thread114911.html

Member Avatar for begueradj

Thank you a lot Mr. Bench
Regards

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 for begueradj

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

Happy new year for you both.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.