Write a program that accepts a string of letters and numbers, and a character, the number of input and output of the character string contained. not case sensitive.

Enter a description:

Enter a string of letters and numbers and of spaces, and a character.

Output Description:

Output of the input string having a number of characters.

Example 1

Entry

ABCDEF A

Export

1

#include <stdio.h>
#include <string.h>
      
int main ()
{
    char STR [10000];
    char CH;
    int len = 0;
    the gets (STR); // i.e. to enter '\ n' is a string terminator
    ch = getchar (); // getchar function also possible
    // scanf ( "% c", & ch); // use scanf () function of the input character are also possible,
    for (int I = 0; I < strlen (STR); I ++)
    {
            IF (STR [I] == CH || STR [I] == CH || STR -32 [I] + CH == 32)
                len ++;
    }
    the printf ( "% D \ n- ", len);
     
    return 0;
}

Published 18 original articles · won praise 3 · views 20000 +

Guess you like

Origin blog.csdn.net/wangxiaolin1992/article/details/81512498