我有这个程序
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char text[30];
    int i,j,n;
    puts("Enter the Text:");
    gets(text);
    n=strlen(text);
    for(i=n;i>=0;i--)
    {
       if(text[i-1]==' '||text[i-1]==NULL )
       {
           for(j=i;text[j]!=' ';j++)
           {
               printf("%c",text[j]);
           }
       }
       printf(" ");
    }
    getche();
}
假设如果我输入的是“我很开心”,那么我的输出是“我很开心”
我不确定我在这个程序中哪里出错了,我没有得到所有的话,我得到的结果是“快乐 [=w am”。请程序员帮助我。
提前致谢。
我找到了答案,谢谢你的帮助,下面是我的代码
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char text[100];
    int i,j;
    puts("Enter the Text:");
    gets(text);
    strrev(text);
    for(i=0;text[i]!='\0';i++)
    {
       if(text[i+1]==' ' || text[i+1]==NULL)
       {
           for(j=i;j>=0 && text[j]!=' ';j--)
            printf("%c",text[j]);
       }
       printf(" ");
    }
    getche();
}