deadlock75
2004-11-02, 03:55 PM
I need some help I am trying to figure out a common error that users often make is that they forget the caps locks on and print text like this:"tHIS IS A SAMPLE of an error". This program works. It changes all uppercase letters to lower case letters. the only problem I don't know is how do I capitalize only the first letter after all the uppercase letters have been lowercase.
#include <stdio.h>
#include <string.h>
main()
{
char sent [30];
int length=0,
i=0,
CapCount=0;
printf ("Enter sentence up to 30 characters:\n" );
gets (sent)l
length=strlen(sent);
for (i=0; i<length; i=i+1)
{
if (sent[i]>65 && sent [i]<91)
{
capCount= capCount+1;
sent[i]=sent[i]+32;
}
}
printf("--------------------------------------\n" );
printf("There was(were) %d capitalized letters.\n" ,
capCount);
printf("The sentence after ridding the caps is as
follows:\n" );
printf(" %s\n", sent);
getchar();
getchar();
return 0;
}
#include <stdio.h>
#include <string.h>
main()
{
char sent [30];
int length=0,
i=0,
CapCount=0;
printf ("Enter sentence up to 30 characters:\n" );
gets (sent)l
length=strlen(sent);
for (i=0; i<length; i=i+1)
{
if (sent[i]>65 && sent [i]<91)
{
capCount= capCount+1;
sent[i]=sent[i]+32;
}
}
printf("--------------------------------------\n" );
printf("There was(were) %d capitalized letters.\n" ,
capCount);
printf("The sentence after ridding the caps is as
follows:\n" );
printf(" %s\n", sent);
getchar();
getchar();
return 0;
}