This is part of my code.
I want to declare an array of List, and I want to be able to pass this array to the functions listed below, so that I can do work on the array (i.e. add/delete nodes). But I have problems getting my head around pointers and references. I hope someone understand what I mean, It's hard to formulate the questions :p

struct Node
	string word;
	Node* next;

struct List
	Node* head;

void placeWordsInBuckets(List &linkedList, string *sort, int d) //What should I write here so that this function can do work on the array of List?
void arrangePointers(List &linkedList)
void rearrangeSortList(List &linkedList, string *sort)
void eraseLinkedList(List &linkedList)

int main
    List* linkedList[26] = { NULL }; // What is the right way to declare an array of List, so that it can be passed on as parameter to other functions?
    string sort[] =  { "ray", "day", "buy" }; 
    for(int d=2;d>=0;d--)
        placeWordsInBuckets(linkedList, sort, d); //What is the right way to pass on the array of List to these different functions?
        rearrangeSortList(linkedList, sort);
6 Years
Discussion Span
Last Post by Azurit

Ill try to help but I too haven't fully grasped the concept of pointers and how they are passed. Last week my homework assignment was to use a linked list of structures!

here is how you pass them

struct list{
	int data;
	struct list *nextptr;

void insert(struct list **start,int value);
void delete(struct list **start,int value);
void reverse(struct list);
void print(struct list *start);

Hopefully someone could clarify but i believe structures are naturally passed by reference, so you have to deference them twice? If you have anymore questions I can try my best to help without giving you code.


I managed to get it done with:

void placeWords(List* linkedList)

//function call
This question has already been answered. 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.