这段代码为什么会Runtime Error啊

这段代码为什么会Runtime Error啊
while循环可以这么写么?

#include 
#include 
int main(){
    char s[400][1500]={'\0'},ch=0;
    int op=0,oq=0,i,t;
    while(scanf("%c", &ch)&&ch!=10)
    {
        if(ch==' '){
            op++;
            oq=0;
        }
        else{
            s[op][oq++]=ch;
        }
    }
    for(i=0;i<=op;i++){
        t=strlen(s[i]);
        if(t==0) continue;
        if(i==0)
            printf("%d", t);
        else
            printf(",%d", t);
    }
    return 0;
}

img

修改如下,供参考:

#include <stdio.h>
#include <string.h>
int main(){
    char s[400][1500]={'\0'},ch=0;
    int op=0,oq=0,i,t;
#if 0
    while(scanf("%c", &ch)&&ch!=10)
    {
        if(ch==' '){
            op++;
            oq=0;
        }
        else{
            s[op][oq++]=ch;
        }
    }
#endif

    while(gets(s[op]) != NULL) op++; //修改 ctrl + z ,结束输入。

    for(i=0;i < op;i++){ //for(i=0;i<=op;i++) 修改
        t=strlen(s[i]);
        if(t==0) continue;
        if(i==0)
            printf("%d", t);
        else
            printf(",%d", t);
    }
    return 0;
}