I am trying to get a string as input from the user and store each character in a linked list (each character getting it's own node). I am using a sentinel for when to stop. I'm not all too familiar with the cin.get() method, and I have been looking around the internet and I think I'm using it correctly, but when I try to compile it goes all wonky on me. Any help is greatly appreciated!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
string vig;
char userval;
cin >> vig;
cin.get (userval, SENTINEL);
while (userval != SENTINEL){
temp = new listnode;
temp -> data = userval;
temp -> next = head;
if (head == NULL)
tail = temp;
else
;
head = temp;
cin.get (userval, SENTINEL);
}