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

 
Word processor
Reply
Posted 2004-11-13, 11:36 AM
I am trying to create a program that a common error that users often make is that they forget the caps locks on an print text like this: "tHIS IS A SAMPLE of an error", this usually happens at the beginning of a new sentence. Write a program to detect this error and fix it. The input will be a long string on keyboard. Basically I am trying to change: "tHIS IS A SAMPLE of an error" to "This is a simple of an error." The only error I got is "isalpha"


#include <stdio.h>

#include <string.h>



main()

{

char sent [30];

int length=0, i=0, capCount=0, endLoop=0;

printf ("Enter sentence up to 30 characters:\n" );

gets (sent);

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;

}

}

for(i = 0; i < length && endLoop == 0; i++)

{

if(isalpha(sent[i]))

{

sent[i] -= 32;

endLoop = 1;

}

}

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-13, 11:51 AM in reply to deadlock75's post "Word processor"
Office XP has this built in.
Old
Profile PM WWW Search
!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics!King_Amazon! simplifies with no grasp of the basics
 
 
!King_Amazon!
 



 
Reply
Posted 2004-11-13, 05:37 PM in reply to deadlock75's post "Word processor"
Format -> Change Case in Word (XP has it, and probably 2000 and eariler as well). Convert to lowercase, and then convert to Sentence case.

The reason that you convert to lowercase first is because Word thinks that all-caps words are supposed to be that way (probably for acronyms and such), except in the case of a complete UPPERCASE sentence. After converting to lowercase, Sentence case will then put it the way you want.

Edit: Unless you're doing this for the cause of "let's make a random program", then more power to you. Now that I look at it, it's probably that, since you're not really reading a text file in, bah.

Code:
   Also, there are code tags that could help you with indenting..

Last edited by BlueCube; 2004-11-13 at 05:42 PM.
Old
Profile PM WWW Search
BlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzBlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
BlueCube
 
 

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 05:25 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.