it seems like every guide is how to create LLL with ints, but I'm having trouble using char pointers. when i run this code, it segfaults immediately
here's my code thus far
struct node
{
char * data;
node * next;
};
void build(node * head);//create list
void manipulate(node * & head);//manipulate list
void display(node * head);//display all
void delete_list(node * head);//delete all nodes in linked list
bool again();//asks user if they'd like to continue
int main()
{
node * head = NULL;
//create list from user1 input
while(again)
build(head);
//displays list
display(head);
//manipulate list as user2 reads through it
manipulate(head);
return 0;
}
void build(node * head)
{
head->next = new node;
char * data = new char;
cout << "where to visit? ";
cin.get(head->data,strlen(data)+1,'
');
head = head->next;
}
See Question&Answers more detail:os