当我使用 scanf_s 时得到 4,但当我使用 fgets() 时得到 1?

I get 4 when I use scanf_s but 1 when I use fgets()?

#include "stdafx.h"
#include <stdio.h>
#include <string.h>

void main()
{
    char s[200];
    int count = 0, i;

    printf("enter the string\n");
    //scanf_s("%[^\n]s", s, sizeof(s));
    fgets(s, sizeof*(s), stdin);
    for (i = 0;s[i] != '[=11=]';i++)
    {
        if (s[i] == ' ')
        count++;
    }
    printf("number of words in given string are: %d\n", count + 1);
    getchar();
}

fgets(s, sizeof*(s), stdin);——是错误的。应该是 sizeof(s)

*(s)是字符(数组的第一个元素),而s是数组。因为单个字符的大小为 1,所以你得到 1.