C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 13th, 2004, 12:34 PM
deadlock75 deadlock75 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 5 deadlock75 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Word Processor

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;

}


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Word Processor


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT