In C language, write a function to count the number of input characters and end the input with the @ character. Call this function in the main function to output statistical results.

#include <stdio.h>

int fun()
{
    char a;
    int n = 0;

    a = getchar();
    while(a !='@' )
    {
        n++;
        a = getchar();
    }
    return n;
}
void main()
{
    int x;
    x = fun();
    printf("%d",x);

Guess you like

Origin blog.csdn.net/liuyang___/article/details/121684430