ポインタを使って文章を単語に分割したい。
私はいくつかのコードを書きましたが、セグメンテーション違反が発生するため、本当に混乱しています。親切に私を助けてください。前もって感謝します。
char **breakstring(char *str)
{
char **temp=(char **)malloc(5*sizeof(char *));
char **temp_store = temp;
while((*str) != '/0')
{
while((*str != '\0') && *str!=' ')
{
**temp=*str;
**temp++;
*str++;
}
str++;
temp++;
}
return temp_store;
}
int main()
{
char **arra;
char *arr="this is a stupid string";
arra=breakstring(arr);
return 0;
}