For any given question I have to take 't' test cases each a string. I have used the following code in c++ for the same:
{ int t;
cin>>t;
while(t--){
string s;
getline(cin, s);
cout<<s;
}
Now the problem with the above code is that it takes a null character for the first test-case. Is there any way to avoid it?
Aucun commentaire:
Enregistrer un commentaire