0

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

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by begueradj
0

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

0

Thank you a lot Mr. Bench
Regards

0

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.

0

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

Happy new year for you both.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.