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 + +,就像我在學校做的。