关于#c语言#的问题:倒排单词,为什么我的程序跑起来后什么都不输出呢

C语言倒排单词实现
#include 
#include 
struct str{
    char str[100];
};
int main()
{
    struct str str1[30];
    int i=0;
    int j=0;
    for(i=0;str1[i].str[0]!='\n';i++){
        while((str1[i].str[j]=getchar())!=' '){
            j++;
        }
        str1[i].str[j]='\0';
        j=0;
    }
    for(i=i-1;i>=0;i--){
        for(j=0;str1[i].str[j]!='\0';j++){
            putchar(str1[i].str[j]);
        }
        printf(" ");
    } 
    return 0;
}


测试样例为
I am a student
输出结果应为
student a am I

为什么我的程序跑起来后什么都不输出呢?

改动处见注释,供参考:

#include <stdio.h>
//#include <>
struct str{
    char s[100];
};
int main()
{
    struct str str1[30];
    int i=0;
    int j=0;
    while(1){ //for(i=0;str1[i].str[0]!='\n';i++)
        scanf("%s", str1[i].s);
        if (getchar() == '\n')
            break;
        i++;
             //while((str1[i].str[j]=getchar())!=' '){
             //    j++;
             //}
             //str1[i].str[j]='\0';
             //j=0;
    }
    for(i;i>=0;i--){
        printf("%s",str1[i].s);
             //for(j=0;str1[i].s[j]!='\0';j++){
             // putchar(str1[i].s[j]);
             //}
        if(i) printf(" ");
    }
    return 0;
}