I have following code:
(我有以下代码:)
int main(){
char sentence[] = "my name is john";
int i=0;
char ch[50];
for (char* word = strtok(sentence," "); word != NULL; word = strtok(NULL, " "))
{
// put word into array
// *ch=word;
ch[i]=word;
printf("%s
",ch[i]);
i++;
//Above commeted part does not work, how to put word into character array ch
}
return 0;
}
I am getting error: error: invalid conversion from 'char*' to 'char' [-fpermissive]
I want to store each word into array, can someone help?
(我收到错误消息:错误: invalid conversion from 'char*' to 'char' [-fpermissive]
我想将每个单词存储到数组中,有人可以帮忙吗?)