#include <string>
std::string input;
std::cin >> input;
用户想要输入“Hello World”。但cin
在两个词之间的空格处失败。我怎样才能cin
完全接受Hello World
?
我实际上是在用结构做这个,cin.getline
但似乎不起作用。这是我的代码:
struct cd
{
std::string CDTitle[50];
std::string Artist[50];
int number_of_songs[50];
};
std::cin.getline(library.number_of_songs[libNumber], 250);
这会产生错误。有任何想法吗?