C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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 March 10th, 2007, 09:11 AM
geocine geocine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 74 geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 39 m 37 sec
Reputation Power: 13
Post String Manipulation Question no. 1

For example i have this string

"peice"

I will need to convert each vowel into a numeric form, what i mean is it's location in the alphabet example.

a = 1 , e = 5 , i = 9 , o = 15 , u = 21

so

"p59c5"

my idea is to convert it into its ascii decimal value and convert it back to string

a will be 97 then i will subtract it to a constant number which is 96

a = 97 - 96 = 1

e = 101 - 96 = 5

i = 105 - 96 = 9

and so forth...

do you think my idea is reasonable?

will i need to use strcat to do something like this

1.if its not a vowel store the character in a temporary string
2.if the next character is a vowel then concatenate it with the temporary string array
3. finally overwrite the original string with the temporary string

Reply With Quote
  #2  
Old March 10th, 2007, 09:32 AM
salem's Avatar
salem salem is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2005
Posts: 2,026 salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 1 Month 2 Weeks 2 h 50 m 24 sec
Reputation Power: 839
How will you decide whether "15" means
- itself, namely "15"
- the two letter pair "ae"
- the single letter "o"
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
UK Voter? Please send a message to Incapability Brown and the rest of Zanu-Labour

Reply With Quote
  #3  
Old March 10th, 2007, 09:45 AM
geocine geocine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 74 geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 39 m 37 sec
Reputation Power: 13
take this as an example...

return = r5t21rn

Reply With Quote
  #4  
Old March 10th, 2007, 11:04 AM
salem's Avatar
salem salem is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2005
Posts: 2,026 salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)salem User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 1 Month 2 Weeks 2 h 50 m 24 sec
Reputation Power: 839
Take this example

aerate -> 15r1t5
orate -> 15r1t5

How do you get back the original?

Is that important?

Reply With Quote
  #5  
Old March 10th, 2007, 12:04 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 3,422 clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level)clifford User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 8 h 11 m 12 sec
Reputation Power: 969
Apart from teh obvious flaws already pointed out:
Code:
letter_num = letter - 'a' + 1;

rather than
Code:
letter_num = letter - 96 ;


I am not sure why you need to do this, but I suggest using a fixed length field (i.e. two) for the vowel coded eg. 'a' = "01". If the input string can never contain digits, then you can assume that any digit pair in the output is a vowel. If the input can itseld fontain digits you will need to be cleverer, and use some sort of preceeding escape sequence.

BTW ... i before e except after c....

Reply With Quote
  #6  
Old March 10th, 2007, 12:52 PM
geocine geocine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 74 geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level)geocine User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 39 m 37 sec
Reputation Power: 13
it is not important to bring it back

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > String Manipulation Question no. 1


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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