Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes

 
Unhappy C programming word processor
Reply
Posted 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;
}
Old
Profile PM WWW Search
deadlock75 is neither ape nor machine; has so far settled for the in-betweendeadlock75 is neither ape nor machine; has so far settled for the in-between
 
deadlock75
 



 
Reply
Posted 2004-11-02, 04:09 PM in reply to deadlock75's post "C programming word processor"
What about just subtacting 32 from str[0]? Another thing, under ctype.h, there are two functions called toLower() and toUpper() which change a character to it's lower case or upper case form.

Last edited by Demosthenes; 2004-11-02 at 04:14 PM.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 



 
Reply
Posted 2004-11-02, 09:42 PM in reply to Demosthenes's post starting "What about just subtacting 32 from..."
That still doesn't work the program works fine the problem is that the program will change any uppercase to lower case I just want the first letter of the sentence to change to uppercase.
Old
Profile PM WWW Search
deadlock75 is neither ape nor machine; has so far settled for the in-betweendeadlock75 is neither ape nor machine; has so far settled for the in-between
 
deadlock75
 



 
Reply
Posted 2004-11-02, 09:48 PM in reply to deadlock75's post starting "That still doesn't work the program..."
And subtracting 32 from str[0] won't do that?
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 09:42 PM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.