View Single Post
Old 02-25-2006, 03:52 PM   #2 (permalink)
kyoryu
Registered User
 
Join Date: Apr 2003
Posts: 34
kyoryu is on a distinguished road
You don't appear to be ever assigning anything to your letterArray.

Code:
     consonant = randomConsonant();
     consonant = letterArray[i];
You're setting consonant to the returned value of randomConsonant() here, and then setting it to what's in the letterArray array at position i. I *think* what you wanted to do was:

Code:
     consonant = randomConsonant();
     letterArray[i] = consonant;
Either way, there's no reason for these to be char pointers rather than simple chars, that I can see. You're not storing strings. This actually goes for your vowel/consonant arrays as well... use the character form ('A') instead of the string form ("A") to store them.

And, frankly, since you're already using at least some STL, you're probably better off simply using a vector< char > instead of a raw C array.

There's also no reason for you to use any global variables in this program. Any variable you're using can be local to main(). Global variables should only by used when absolutely necessary.

And indent your code. It makes it easier to find errors. (apologies if the lack of indentation is a cut/paste issue).

With all due respect, it looks like this is homework. I'd suggest reading over the chapters a bit more... it looks like you're misunderstanding a couple of basic concepts. Learning what the code is actually doing in this case will help you out a lot over the long run. Build a house on a solid foundation, etc.
kyoryu is offline   Reply With Quote