|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#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 |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
take this as an example...
return = r5t21rn |
|
#4
|
||||
|
||||
|
Take this example
aerate -> 15r1t5 orate -> 15r1t5 How do you get back the original? Is that important? |
|
#5
|
||||
|
||||
|
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.... ![]() |
|
#6
|
|||
|
|||
|
it is not important to bring it back
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > String Manipulation Question no. 1 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|