是的,C++中的cin.getline函数能够接收空格。cin.getline函数可以读取一行输入,包括空格字符,直到遇到换行符为止。因此,它可以用来接收包含空格的字符串输入。示例代码如下: #include <iostream> using namespace std; int main() { char str[100]; cout << "请输入包含空格的字符串:" << endl; cin.getline(st...
因为输入有空格,可以用getline(cin, s)来接收输入字符串。_牛客网_牛客在手,offer不愁
// cin.get(ch);//刚刚少了这一句,也就无法继续去接收剩余输入流中的字符,导致程序无法执行 // } // cout << endl<< "空格数为:" << spaces << endl; // cout << "总的字符数为:" << total << endl; // cin >> zero; //防止DOS闪退 //} /* 逻辑运算符 */ /* 01)逻辑或OR(||)...