C++怎么从命令行接收一段字符串并保存到字符数组中

C++如何从命令行接收一段字符串并保存到字符数组中。
RT.

------解决方案--------------------
字数确定么?如果确定最大范围可以这么写,按回车结束输入.

C/C++ code

#include <iostream>
using namespace std;

int main(void)
{
    char a[100];

    cin>>a;

    cout<<a;
    return 0;
}

------解决方案--------------------
建议用string的
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
cin >> str;
cout << str << endl;
return 0;
}
------解决方案--------------------
C/C++ code
#include <iostream>
using namespace std;

int main(void)
{
    char a[100]={0};//建议加个这个清空下,否则在一些平台下会出现乱码

    cin>>a;

    cout<<a;
    return 0;
}