バグではないかもしれませんが、何が悪いのかわかりません。私の最初のエントリは、2回目の反復でstr1に対して繰り返され、それ以降も同じです。最初の反復だけがうまくいきます。
#include <iostream>
#include <string>
using namespace std;
int main () {
cout << " \n Enter two words. \n " ;
char c = 'y';
string str;
string str1;
while (c == 'y'){
getline(cin,str);
getline (cin,str1);
cout << " \n\n str : " << str << " str1 : " << str1 ;
cout << " \n Continue ? \n " ;
cin >> c;
}
return 0;
}
出力は次のとおりです。
2つの単語を入力してください。 こんにちは世界 これはミスターです str:hello world str1:これはmrです 継続する ? y こんにちは世界 str:str1:hello world 継続する ? n