Tuesday, August 17, 2010

How do I point a position in an array to a linked list?

eg. char arr[100];





I want to point position arr[5] to a linked list of strings.


The pointer the linked list is called head. So I want to point arr[5] to head.





Thanks

How do I point a position in an array to a linked list?
If you want to have an array of pointers, then you're going to want to make the array type be whatever the type of reference is that you're using.





So, i would think you'd want to make the array type be the same as the linked list object type that you're using, and then set that array position equal to the reference to the head object.





Now, when i say this, i'm thinking in Java. It may work somewhat differently in C++, and whatnot.
Reply:You can't, linked lists are objects and Array's can only store primitive data types.





You could use an Array List
Reply:http://www.eecs.harvard.edu/~ellard/Q-97...


No comments:

Post a Comment