I am trying to display the data from my list using an array that i pass to my class function display(). I can't seem to find any examples for what I am doing in the tutorials. When I attempt to display the list I get the following error.
Code:
Unhandled exception at 0x102aec80 (msvcr80d.dll) in list.exe: 0xC0000005: Access violation reading location 0x00000000.
I was hoping for a simpler way to accomplish this. But I am very rusty and have to use the trial and error approach. Thanks for any help.
Code:
//=========================================================
// DisplayInput
//=========================================================
void displayinput(list & mylist)
{
int arraysize = 0;
char ** array;
mylist.display(array, arraysize);
for(int i = 0; i < arraysize; i++)
{
cout << array[i] << endl;
}
for(int i = 0; i < arraysize; i++)
{
delete [] array[i];
}
delete [] array;
return;
}
//==========================================================
// Display
//==========================================================
int list::display(char **& array, int & arraysize)
{
int i = 0; //for traversing array
arraysize = num_in_list;
array = new char*[arraysize];
node * curr;
curr = head;
while(curr)
{
array[i] = new char[60];
array[i] = '\0';
strcat(array[i], curr->fname);
strcat(array[i], " " );
strcat(array[i], curr->lname);
++i;
curr = curr->next;
}
arraysize = num_in_list;
return 0;
}