【发布时间】:2012-11-01 21:17:57
【问题描述】:
可能重复:
Extract multiple words to one string variable
changing the delimiter for cin (c++)
我在使用 cin 时遇到问题。我的代码:
cout << "Enter Main Keyword: ";
cin >> mainKeyword;
cout << "==========" << endl;
cout << "Enter Secondary Keyword: ";
cin >> secondaryKeyword;
当我为 mainKeyword 变量输入“关键字”(不带引号)时,程序会自动将“key”分配给 mainKeyword,将“word”分配给 secondaryKeyword,让程序考虑两个或多个字符串的代码是什么作为一个输入?
谢谢。
【问题讨论】: