-1
當這個運行我想不能輸入任何空格cin
我可以使用什麼格式說明?如何告訴cin不允許輸入空格? (C++)
他們在<string>
什麼東西讓我這樣做?
#include <iostream>
#include <string>
using namespace std;
int main(){
string yy;
cin >> string;
/*when this runs I want to not be able to enter any spaces in `cin`
what format specifier can I use for this? is their anything in `<string>` that lets me do this?
*/
return 0;
}
'C++'無法控制允許用戶通過標準輸入('std :: cin')輸入的內容。所有你能做的就是抱怨,如果他們給你空間或者可能忽略它們,這取決於你想要做什麼。 – Galik
我試圖忽略空格。當空格在2個字符串之間時,我的程序出乎意料地行爲。意想不到的行爲。所以我想忽略這些空格,並只讓第一個字符串傳遞給我的其他函數。 – Tristan