| ashish verma (32) | |
|
/******************STRUCT DEFINATION*************************/ struct linkqueue { string addr; struct linkqueue *link; }; struct linkqueue *start = NULL; /***********************FUNCTION TO CREATE A NODE*************/ void insert(struct linkqueue **q, string addr) { struct linkqueue *start; struct linkqueue *temp; start = *q; temp = (struct linkqueue *) malloc (sizeof(struct linkqueue)); temp->addr = addr; temp->link = NULL; if(*q == NULL) { *q == temp; } else { while(start->link != NULL) { start = start->link; } start->link = temp; } } /******************MAIN FUNCTION WHERE A STRING IS SENT TO BE INSTERTED INTO LINKED LIST****************/ void linkstore (string addr) { int i = 0; while (addr[i] != '\0') { cout<<addr[i]; ++i; } cout<<"\n"; insert(&start, addr); } | |
|
Last edited on
|
|
| ashish verma (32) | |
| The error is caused in the line I've written in Bold letters , this is probably some kind of illegal memory assignment dealing with strings. | |
|
|
|
| mbisht (4) | |
|
The error is at line temp = (struct linkqueue *) malloc (sizeof(struct linkqueue)); please use new to allocate memory temp =new struct linkqueue; Thanks .Madan | |
|
|
|