Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Separate alphabetic and numeric characters from the string and put them into two arrays respectively.
Separate alphabetic and numeric characters from the string and put them into two arrays respectively.
/*

Separate alphabetic and numeric characters from the string and put them into two arrays respectively.

*/

# include & ltstdio.h & gt

void main()

{

char *p,s[80],zm[80];

int SZ[80];

Int alpha, spaces, numbers, others;

int I;

Alpha = space = number = other = 0;

Printf ("input string:");

Obtain;

for(p = s; *p! ='\0'; p++)

If ((* p> =' a'& * p< =' z') || (* p > = ' A ' & amp& amp* p & lt= ' Z '){ zm[alpha++]= * p; }

else if(* p = = 32)space++; //The ASCII code for spaces is 32.

else if(* p & gt; = ' 0 ' & amp& amp* p & lt= ' 9 '){ SZ[digit++]= * p-48; }

else other++;

Printf("alpha:%d space: %d number: %d other: %d\n ",alpha, space, number, other);

Printf ("The content of the character array is:");

for(I = 0; I< alpha; i++)

{

printf("%c ",zm[I]);

}

printf(" \ n ");

Printf ("The content of digital array is:");

for(I = 0; I < number; i++)

{

printf("%d ",SZ[I]);

}

printf(" \ n ");

}