#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
cin >> str;
const char *c = new char[5];
c = str.c_str();
for(int i=0;i<5;i++)
cout<<c[i];
cout << endl;
}
结果1.
fds
fds
结果2.
fdsafdsafdsa
fdsaf
接收输入string转char数组
最新推荐文章于 2023-02-05 02:10:41 发布