我正在尝试使用字符数组输入单词序列。我不想使用STL中的字符串。我要去哪里错了?
int n;
cout<<"Enter the number of words:";
cin>>n;
char **s = new char*[n];
for(int i=0;i<n;i++)
{
char *s = new char[10];
cin>>s[i];
}
使用
char ch[n+1];
for(int i = 0;i<n;i++)
`cin>>ch[i];
ch[n] = '\0';
cout<<ch<<endl;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句