Thread: test score
View Single Post
Old Sep 23rd, 2006, 10:09 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
What is this?
                  if(test[i]!=' ')  
                      { score=score+0;}
If you don't do anything to the score, it's the same as adding zero. I would write it like this:
if (test [i]  != ' ')
{
   // There's an answer
   if (test [i] == key [i]) score += 2;
   else score -= 1;
}
Secondly, it would be better to use the string class. I would read the entire line and pluck the two parts out as substrings.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote