按照相反的单词顺序显示词组
程序代码:#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 100
void fan(char *str)
{
char word1[N],word2[N],space[N];
int i,j,k,word=0,n;
for(i=0,j=0,k=0,n=0;str[i]!='\0';i++)
{
if(isgraph(str[i])) //遇到字母时,把空格和单词互换
{
j++;
if(k!=0)
{
strncpy(space,str+n-k,k);
strcat(space,word1);
strcpy(word1,space);
}
k=0;
}
else //把单词2和“空格+单词1”互换
{
k++;
if(j!=0)
{
strncpy(word2,str+n-j,j);
strcat(word2,word1);
strcpy(word1,word2);
}
j=0;
}
n++;
}
if(j!=0)
{
strncpy(word2,str+n-j-1,j);
strcat(word2,word1);
strcpy(word1,word2);
}
str=word1;
}
int main(void)
{
char str[N]="see you later";
fan(str);
puts(str);
return 0;
}按照相反的单词顺序显示"see you later",结果为“later you see”,请问以上程序有什么错误?








