Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Stupid counting error
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dan_




PostPosted: Fri Oct 06, 2006 3:11 pm   Post subject: (No subject)

md wrote:

As for -Wall... what IDE are you using (since you obviously are...)?


I'm using DevC++

I'll go fix the variables to be more descriptive, but does anyone know why my guess number isn't always correct?
Sponsor
Sponsor
Sponsor
sponsor
Dan_




PostPosted: Fri Oct 06, 2006 3:28 pm   Post subject: (No subject)

Problem solved! As I was testing it and trying to see why it was giving me the wrong number I noticed that if I played multiple times, my num_Guesses was holding the old guess number, so I moved the variable definition further down in the code and fixed it.

Thanks for all the help guys!
Null




PostPosted: Fri Oct 06, 2006 5:44 pm   Post subject: (No subject)

I just want to add that as an alternative to names like numb_guesses, names like NumbGuesses or numberSum also follow common convention.

Choose whichever you prefer, but once you choose a style, try to stick to it. Smile
Dan_




PostPosted: Fri Oct 06, 2006 8:50 pm   Post subject: (No subject)

Will do Null, I'm still trying to figure out my style. Laughing
bugzpodder




PostPosted: Mon Oct 09, 2006 5:31 pm   Post subject: (No subject)

wtd wrote:
As for Hungarian notation (prefixing the name of the variable with the type), it is wholly worthless. Just use meaningful variable names.


disagree. while i dont support these naming styles, it sometimes helps to figure out what type a variable is easily if your compiler doesnt provide this functionality.

once I had. for (i=0;i<v.size()-1;i++) ...
well guess what? v.size() is an unsigned int, so 0 - 1 get casted to 0xFFFFFFFF and i get an infinite loop when the vector is empty. So if someone wrote code like:

iSize = v.size() - 1;
for (i=0;i<iSize;i++) ...
then when debugging it might have jumped out, than something like

numIterations = v.size() - 1;
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 20 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: