私はループがあり、文字列を読み取るたびに空白の入力を読み取る方法がわかりません。つまり、ユーザーが何も入力せずにEnterキーを押すと、そこに残ります。
それを文字列として読み、次の入力に移動したいのはコードです
int times = 4;
while(times--)
{
string str;
cin>>str;
---then some other code to play with the string---
}
getline()を使用して行全体を読み取る必要があります。次に、読み取った文字列をトークン化する必要があります。
getlineの使用とstringstreamを使用したトークン化に関するリファレンスを次に示します。
char blankline[100];
int times = 4;
while(times--)
{
//read a blank line
cin.getline(blankline,100);
---then some other code to play with the string---
}