Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to calculate the character length in C language?
How to calculate the character length in C language?
# Including

Master ()

{

tea

str[ 10000];

/* Define a character with the length of 10000 */

Internationalorganizations (same as international organizations)

Me;

Internationalorganizations (same as international organizations)

Blank = 0;

/* space */

Internationalorganizations (same as international organizations)

big _ string = 0;

/* capital letters */

Internationalorganizations (same as international organizations)

small _ string = 0;

/* lowercase letters */

Internationalorganizations (same as international organizations)

Number = 0;

/* Numbers */

Internationalorganizations (same as international organizations)

rest = 0;

/* Others */

Printf ("Please

let go

a

string:\ n ");

gets(str);

/* Enter segmentation characters */

for(I = 0; str[i]! ='\0'; i++)

{

if(str[i]== '

)

/* Please note that you must enter a space */

blank++;

other

if(str[i]>= ' A ' & amp& ampstr[I]& lt; ='Z ')

big _ string++;

other

if(str[i]>= ' a ' & amp& ampstr[I]& lt; ='z ')

small _ string++;

other

if(str[i]>= ' 0 ' & amp& ampstr[I]& lt; ='0')

Number++;

other

rest++;

}

printf("The

result

Yes: \ n ");

printf(" blank = % d \ nbig _ string = % d \ n small _ string = % d \ n number = % d \ n rest = % d \ n ",

Blank, large _ string, small _ string, number, the rest);

getch(); }