#define t() int test; cin>>test; while(test--)
int main() {
t() {
string a;
stack<char> s;
bool flag;
cin.ignore();
getline(cin,a,'\n');
cout<<a[0];
//more code
}
}
I do not understand why is getline skipping one charracter for the second time. For example, if I take the input
2
<<>>
<>
The output coming is:
<
> // skips '<'
If I use getline without cin.ignore, it just simply skips the input.
Aucun commentaire:
Enregistrer un commentaire