C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 17th, 2013, 07:31 PM
amitj93 amitj93 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 amitj93 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 6 sec
Reputation Power: 0
String manipulation

Hey guys,

I wrote the following code so far(at the very bottom), which asks the user to input a string less than 100 characters such as "Programming's Hard!"

I am trying to get it so that the program will be able to restate the string that the user entered above, but do three things differently:
1) switch it to all capital letters if its not already in capital,
2) remove any spaces that may be in the string
3) remove any no alphabetic symbols (i.e. '!')

the output should look like this:

Enter String: Programming's Hard!

String to Encode: PROGRAMMINGSHARD



If you guys could help me understand how to do any of the three things, i would really appreciate it, i am really lost as to how to go about it.

thanks!

Code:
#include <stdio.h>
#include <string.h>

//Define all Variables
char string[100];
int count;      

// Prompt User to Enter String

int array[27]= {0b0001,0b001111,0b10110,0b00000,0b011,0b11011,0b001100,0b1001,0b0100,
                0b11001011,0b1100100,0b00001,0b11000,0b0101,0b0010,0b001110,0b1100101000,0b1010,
                0b1000,0b111,0b10111,0b110011,0b11010,0b1100101001,0b001101,0b1100101010,0b1100101011};
int main() {

do{

printf("Enter String: ");
scanf("%s", string);

for(count=0; count<=strlen(string); count++) { 
   if(string[count]>97 && string[count] >= 122)
      string[count]=string[count]-32;
}

printf(" String to Encode: %s", string);

}
while(strcmp(string, "quit")); 
}

Reply With Quote
  #2  
Old February 18th, 2013, 01:03 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,838 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 17 h 9 m 51 sec
Reputation Power: 1774
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > String manipulation

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap