Singly Linked List in C++ help???

i have sorted singly linked list but my problem is starting after it.i have to print the info within the range defined by user input.i tried i little but i need help.

void printUserInput()
{
char x,y;
node * temp=head;
cout<<"Please enter two latter"<<endl;
cin>>x;
cin>>y;

if(x>=y)
{
cout<<"The second user input must come after the first one."<<endl;

}

else
{
while(temp->surname[0]==x){
temp=temp->next;
}

while(temp->surname[0]==y){
cout<<temp->id<<" ";
cout<<temp->surname<<" ";
cout<<temp->name<<" ";
cout<<temp->age<<" "<<endl;
temp=temp->next;
}
}
}
The second user input must come after the first one.

If I enter A then B, then this is saying that B must come after A, which means A then B - the same as what I originally inputted...

As for how to access the elements in a range, iterate the list X times and then output the list after that Y-X times.
if u enter a then b ,then as a<b ,it enter to else condition
the problem is in else condition,what's wrong with it?i can't understand.
LB wrote:
As for how to access the elements in a range, iterate the list X times and then output the list after that Y-X times.
Topic archived. No new replies allowed.