The number of words [C language] Enter a string, statistical them, the first letter of the first word to uppercase, and rewritten string output

#include<stdio.h>
int main()
{
    char a[100];
    int i, j=1;

    printf ( " Please enter a string of characters: " );
    gets_s(a);
    for (I = 0 ; A [I] =! ' \ 0 ' ; I ++) / * find the number of words * /
    {
        if (a[i] == ' ')
            j += 1;
    }
    the printf ( " number of words:% D \ n- " , J);
     IF (A [ 0 ]> = ' A ' && A [ 0 ] <= ' Z ' ) / * Analyzing first capitalization and converted * / 
        A [ 0 ] - = 32 ;
     for (I = 0 ; A [I] =! 0 ; I ++ )
    {
        printf("%c", a[i]);
    }
  
}

 

Guess you like

Origin www.cnblogs.com/HGNET/p/11979897.html