小白菜鸡提问!输入多个数组串问题

img


这个不知道为啥好像那个while循环没起作用,最后输出一直是0😭

img


下面是我的代码
#include
int main()
{
int i=0,k=0;
char s[20];
while((s[i+1]=getchar())=='\n'&&(s[i]=getchar())=='stop')
{
if(s[i]=='\n'||s[i]==' ')
{
k--;
}
k++;
i++;
}
printf("%d",k);
}

s[i]=getchar())=='stop'
stop是字符串,怎么可能和字符相等呢

#include <stdio.h>
#include <string.h>
int main()
{
   char word[30];
    int count = 0;
   scanf("%s",word);
   while(strcmp(word,"stop") != 0)
    {
          count++;
          scanf("%s",word);
    }
    printf("单词数量:%d\n",count);
}

https://ask.csdn.net/questions/7830575?answer=53977771&username=Z65443344&utm_medium=notify.im.haveAccept.a
你这代码写的毫无逻辑可言
'stop'又是啥,一个字符里能放下4个字符?