Nominull comments on Positive Bias Test (C++ program) - Less Wrong

26 Post author: MBlume 19 May 2009 09:32PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (75)

You are viewing a single comment's thread.

Comment author: Nominull 20 May 2009 01:23:54AM 1 point [-]

Program could use some protection against invalid input, along the lines of

if(!(cin >> n1 >> n2 >> n3)) { ndone=false; }

and if you really wanted to get fancy you could throw in an error message when it occurs

it's not nice to have a program that goes into an infinite loop if you give it a letter instead of a number

Comment author: MBlume 20 May 2009 01:29:48AM *  0 points [-]

wow, I didn't know iostream was that badly broken.

Fixed, though it now aborts completely if you give it a letter.

Comment author: CronoDAS 20 May 2009 04:33:34AM 0 points [-]

It could be worse. The C++ keyboard console input libraries are, indeed, horrible - but you could be stuck trying to do the same thing in plain old C. ::shudders::