从键盘读取用户输入直到遇到#字符,编写程序统计读取的空格数目和所有 其他字符数目

从键盘读取用户输入直到遇到#字符,编写程序统计读取的空格数目和所有
其他字符数目,要求:
使用getchar()输入字符;
使用结构体变量进行字符的数目统计;

#include<stdio.h>
struct s{
    int spaces,newline,character;
}s1;
int main()
{
    s1.character=0;s1.newline=0;s1.spaces=0;
    printf("请输入字符:");
    char ch;
    while(1)
    {
        ch=getchar();
        if(ch == '#')
        {
            break;
        }
        else if(ch ==' ')
        {
            s1.spaces++;
        }
        else if(ch == '\n')
        {
            s1.newline++;
        }
        else
        {
            s1.character++;
        }
    }
    printf("空格符%d个,换行符%d个,其他符号%d个\n",s1.spaces,s1.newline,s1.character);
    return 0;
}