C++ 字符串不是';t用c+打印整行+;?

C++ 字符串不是';t用c+打印整行+;?,c++,C++,我是C++的初学者,我正在尝试打印此程序: Enter string: This is a test Output: This Press any key to continue . . . 这是我的节目: #include<iostream> using namespace std; int main(){ char name[100]; cout << "Enter string: " << endl;

我是
C++
的初学者,我正在尝试打印此程序:

    Enter string:
    This is a test

Output:
    This

Press any key to continue . . .
这是我的节目:

#include<iostream>
using namespace std;

int main(){
    char name[100];
    cout << "Enter string: " << endl;
    cin >> name;

    cout << name << endl;
}
#包括
使用名称空间std;
int main(){
字符名[100];
姓名;

试试看
cin.getline(name,sizeof(name));
而不是
cin>>name;

cin>>name;
-->-->
cin.getline(name,sizeof(name));
@BLUEPIXY请回答这个问题,这样我就可以把它调高了。哇..这个也可以用了..谢谢:)@WhozCraig:“缺少的是你需要一个std::字符串,而不是字符[]缓冲区,“…如果我使用
字符串
我会得到一个错误..看到了吗