#include <stdio.h>
#include <string.h>
#include <ctype.h>
void
uppercase (char in[], char out[])
{
int i;
for (i=0; i<=strlen(in); ++i)
out[i] = toupper(in[i]);
}
void
onlyletters (char in[], char out[])
{
int i, j;
j=0;
for (i=0; i<=strlen(in); ++i)
{
if (isalpha(in[i]) || in[i]=='\0')
{
out[j] = in[i];
j=j+1;
}
}
}
int
main (void)
{
char before[50], after[50];
printf ("Enter a phrase: ");
fgets (before, 50, stdin);
before[strlen(before)-1] = '\0';
printf ("Original sentence: %s.\n", before);
uppercase (before, after);
printf ("In uppercase: %s.\n", after);
onlyletters (before, after);
printf ("Only the letters: %s.\n", after);
return (0);
}
Enter a phrase: Monday, March 14, 2005
Original sentence: Monday, March 14, 2005.
In uppercase: MONDAY, MARCH 14, 2005.
Only the letters: MondayMarch.