cin.ignore and getline are not working properly

[code]
int main()
{
string command ;
cin>>command;

if((command=="UNLOCK")||(command=="unlock"))
{
cout<<"~"<<endl;
cout<<"UNLOCKED"<<endl;
give_command();
}
else cout<<"locked";
}

void give_command()
{

string command1, command2, command3;
cin.ignore();
getline(cin,command1);
stringstream ss(command1);
getline(ss,command2,' ');
getline(ss,command3,' ');
cout<<command2<<endl;;
cout<<command3<<endl;

if ((command2=="A")||(command2=="a"))
{
do this

}
else if((command2=="B")||(command2=="b"))
{

do this
}
else if((command2=="C")||(command2=="c"))
{
do this
}
else if((command2 =="D") ||(command2== "e"))
{
do this
}
else if((command2 =="E") ||(command2== "e"))
{
do this
}
else if((command2 =="F") ||(command2== "f"))
{
do this
}
else
{
cout<<"invalid"<<endl;
cout<<"enter again"<<endl;
give_command();

}

}


/code]

hey

in this code....i have been trying to execute some commands
but this cin.ignore() and getline functions are giving me troubles

if i do not use cin.ignore() then all the if blocks of give_command are skipped and on console i can see

invalid
enter again

after using cin.ignore()
getline is skipping first character of my input and also command is not getting executed.

please help

Topic archived. No new replies allowed.