1
把这个字符串:Separing在单独的单词串
asking a question is easy
我想在一个while循环
- 采取第一个字
asking
, - 检查一些有关它的功能,
- 然后转到下一个单词
a
- 等等直到字符串结尾
单词可以被一个或多个空格隔开。
编辑:
我想解释时,我竟然犯了一个错误。在这里我一直在努力:
int main()
{
cout<<"string="; gets(string);
cout<<"template="; cin>>template;
while (i<strlen(string))
{
k=0;
while (string[i]!=' ')
{
word[k]=string[i];
i++; k++;
}
if (function(string,word)==1) count++;
while (i<strlen(s) && string[i]==' ')
i++;
}
cout <<"count="<<count;
}
我想坚持一些旧的/基本的C + +,就像我在学校做的。