|
-
April 5th, 2011, 10:00 AM
#11
Re: Counting characters help
 Originally Posted by LogicWavelength
I know that two functions is totally unnecessary - but the book's assignment specifically states to make two.
Programming is an exact science -- if the description says two separate functions:
Code:
int countVowels(const char* userInput)
{
return countHelper(userInput, "aeiou");
}
int countConsonants(const char* userInput)
{
return countHelper(userInput, "bcdfghjklmnpqrstvwxyz");
}
countHelper is the function I mentioned in my post. See, two separate functions. Also, a good beginner programmer would see that there is redundancy, and would have done something similar to what I wrote above.
Would this be what you're asking for:
Code:
for(int foo = 0; foo < vowel; foo++)
No.
There is a library function called strchr() that seaches for a character in a string. I suggest you use it instead of writing another loop.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; April 5th, 2011 at 10:05 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|