I am trying to make a linked list from space separated integer input.
Input:
- Number of nodes
- Space separated input
int main()
{
int n;
cout<<"Enter number of nodes";
cin>>n;
cout<<"\nEnter data"<<endl;
int temp;
lNode *head = NULL;
while(cin>>temp)
{
CreateLinkedList(&head,temp);
}
PrintLinkedList(head);
return 0;
}
Here I am not getting how to limit the user input to the number of nodes which he has given as first input. Is there any other way to get user input?