Pages

4.17.2013

Coding Derp of the day

As I write more and more code in my CS classes, this type of post could become a regular thing.


This code actually works.

The function above simply asks the user if he/she would like to go again, used for whatever.  If the user answers yes or no, the function returns 1 or 0.  Otherwise it loops again until the user inputs yes or no.  The "for" loop capitalizes each character in the response so that the input string can be of any case.

Here's the derp I made.  I forgot to initialize "i" to 0 (line 57) each time the main loop runs, so if the user entered an invalid answer the first go around, "i" was incremented to 10 and never reset.  Any subsequent go-rounds would never enter the for loop to capitalize the input, therefore entering "yes" was not being considered as valid because "yes" is not the same as "YES"!

Anyway, I spent about 30 minutes debugging this one thinking it was some sort of input buffer issue with new line characters.  Hope that somebody else can learn from my mistake.

1 comment:

Anonymous said...

We have to deal with each person's issues as severe no matter what they say while trying to get the service removed. Unfortunately no we won’t take away BetBlocker until the chosen restriction has expired. When activating BetBlocker you both comply with phrases of use explicitly stating that you just will be unable to take away this block until your restriction interval has concluded. While we are happy to help resolve technical issues we will not disarm the software unless your selected exclusion interval has concluded. Sleep mode - Our testing shows that while BetBlocker is active and the cellphone not getting 1xbet used the battery will drain in 96 hours. Under the identical conditions the battery life while BetBlocker was not active was ninety seven hours.