| | |
need help with tricky string modyfication
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 49
Reputation:
Solved Threads: 0
Let's assume that the 100th user inputs his name as: Jackson Michael.
I would like my prog to print to the file the reference, which would be combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).
in case of Jackson it would be: JCKSN100
any ideas how to accomplish that? as of right know all the inputted names are in an array and each element is a plain string.
Thanks in advance
I would like my prog to print to the file the reference, which would be combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).
in case of Jackson it would be: JCKSN100
any ideas how to accomplish that? as of right know all the inputted names are in an array and each element is a plain string.
Thanks in advance
Last edited by DeathEvil; Jul 29th, 2007 at 1:51 pm.
•
•
•
•
Perhaps begin with a function called 'isVowel()', which returns true or false, depending on the type of letter passed to it.
Then implement your own 'strcpy' like function, which makes use of isVowel()
Last edited by Aia; Jul 29th, 2007 at 2:47 pm.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
•
•
•
•
Thanks guys, I will try to make something out of it, but that sounds like a good starting point. If anyone alse has any suggestions, please feel free to input your thoughts
C Syntax (Toggle Plain Text)
* * abbr.c * Converts string to upper case and removes vocals */ #include <stdio.h> #include <ctype.h> int main( void ) { char name[]= "Jackson100"; /* given string */ int i = 0, x = 0; /* indexes */ int len = strlen( name ) + 1; /* Make string to upper case and removing vocals */ for( i = 0; i < len; i++ ) { switch( name[i] = toupper( name[i] ) ) { case 'A': break; case 'E': break; case 'I': break; case 'O': break; case 'U': break; default: { name[x] = name[i]; ++x; } } } printf( "%s\n", name ); /* for testing purposes */ getchar(); return 0; } /* output: JCKSN100 */
Last edited by Aia; Jul 29th, 2007 at 4:02 pm.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
More homework on a plate, very disappointing
You should have waited more than 5 minutes to see what the OP could come up with before blurting out an answer.
So instead of the OP getting to practice the all important analytical and problem solving skills, they're going to have to try to practice them on the next problem instead (only that will be so much harder now).
Oh well, nevermind, no great loss I suppose.
You should have waited more than 5 minutes to see what the OP could come up with before blurting out an answer.
So instead of the OP getting to practice the all important analytical and problem solving skills, they're going to have to try to practice them on the next problem instead (only that will be so much harder now).
Oh well, nevermind, no great loss I suppose.
•
•
Join Date: Jul 2007
Posts: 49
Reputation:
Solved Threads: 0
•
•
•
•
More homework on a plate, very disappointing![]()
You should have waited more than 5 minutes to see what the OP could come up with before blurting out an answer.
So instead of the OP getting to practice the all important analytical and problem solving skills, they're going to have to try to practice them on the next problem instead (only that will be so much harder now).
Oh well, nevermind, no great loss I suppose.
![]() |
Other Threads in the C Forum
- Previous Thread: Palindromes...but determining using variables
- Next Thread: structure address changes when returned.
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi






