Here's what i have so far: :)
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define N 25
int main(void)
{
char s1[N];
char s2[N];
char *upper, *lower;
char *p, *q;
size_t n1, n2;
printf( "Please enter first string: " );
fgets( s1, N, stdin );
printf( "Please enter second string: " );
fgets( s2, N, stdin );
n1 = 0; n2 = 0;
for ( p = s1; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) ++n1;
else if ( islower( ( unsigned char )*p ) ) ++n2;
}
for ( p = s2; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) ++n1;
else if ( islower( ( unsigned char )*p ) ) ++n2;
}
upper = NULL; lower = NULL;
if ( n1 && ( upper = ( char * )malloc( n1 + 1 ) ) )
{
q = upper;
for ( p = s1; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) *q++ = *p;
}
for ( p = s2; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) *q++ = *p;
}
*q = '\0';
}
if ( n2 && ( lower = ( char * )malloc( n1 + 1 ) ) )
{
q = lower;
for ( p = s1; *p; ++p )
{
if ( islower( ( unsigned char )*p ) ) *q++ = *p;
}
for ( p = s2; *p; ++p )
{
if ( islower( ( unsigned char )*p ) ) *q++ = *p;
}
*q = '\0';
}
if ( upper ) printf( "Upper: %s\n", upper );
if ( lower ) printf( "Lower: %s\n", lower );
free( upper );
free( lower );
return 0;
}
The program output might look like
Please enter first string: GREENblue
Please enter second string: busCAR
Upper: GREENCAR
Lower: bluebus
If your compiler supports Variable Length Arrays then you could use VLA(s) instead of the dynamically allocated arrays.
Here is a program that uses VLA
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define N 25
int main(void)
{
char s1[N];
char s2[N];
printf( "Please enter first string: " );
fgets( s1, N, stdin );
printf( "Please enter second string: " );
fgets( s2, N, stdin );
size_t n1 = 0, n2 = 0;
for ( const char *p = s1; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) ++n1;
else if ( islower( ( unsigned char )*p ) ) ++n2;
}
for ( const char *p = s2; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) ++n1;
else if ( islower( ( unsigned char )*p ) ) ++n2;
}
char upper[n1 + 1];
char lower[n2 + 1];
if ( n1 )
{
char *q = upper;
for ( const char *p = s1; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) *q++ = *p;
}
for ( const char *p = s2; *p; ++p )
{
if ( isupper( ( unsigned char )*p ) ) *q++ = *p;
}
*q = '\0';
}
if ( n2 )
{
char *q = lower;
for ( const char *p = s1; *p; ++p )
{
if ( islower( ( unsigned char )*p ) ) *q++ = *p;
}
for ( const char *p = s2; *p; ++p )
{
if ( islower( ( unsigned char )*p ) ) *q++ = *p;
}
*q = '\0';
}
if ( n1 ) printf( "Upper: %s\n", upper );
if ( n2 ) printf( "Lower: %s\n", lower );
return 0;
}