#include "iostream"
using namespace std;
int main()
{
char *p[5] ;
for (int i = 0; i < 5; i++)
{
p[i] = (char *)calloc(100, sizeof(char));
}
cout << "please input an number such as \"one hundred"
" and twenty five\"" << endl;
for (int i = 0; i <= 5; i++)
{
char ch = cin.get();
while (ch != ' ' || ch != '\0')
{
*p[i]++ = ch;
ch = cin.get();
}
if (ch == '\0') break;
}
for (int i = 0; i < 5; i++)
{
cout << p[i];
}
return 0;
}
我想从键盘输入到一段字符串,然后将这段字符串从空格处拆分开到一个指针数组里面,知道字符串结尾
现在我我输入 one hundred and twelve 的时候老是不成功
请高手帮我看下
跃然一笑