Skip to main content

Timeline for Summing user input

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Jan 30, 2015 at 8:01 comment added user52380 @200_success this is a pretty cool method for catching CTRL characters such as EOF. clever as usual.
Jan 28, 2015 at 11:16 comment added Ismael Miguel I think it would be a bad idea, since the code I would write wouldn't be robust either. I'm not saying I disagree with your suggestion. I'm just saying that it is over-complicated for a simple program.
Jan 28, 2015 at 11:07 comment added 200_success @Ismael I frequently mention goto fail in my reviews, when programmers omit braces for a statement on the next line. Same-line statements should be immune to that kind of failure, though. Unfortunately, the original simple program is not robust. I encourage you to write a review with a better suggestion.
Jan 28, 2015 at 10:56 comment added Ismael Miguel I understand why you don't discuss braces, but the lack of it might contribute for really bad, bug-prone code. This happened before! I've read a while ago about a vulnerability in iOS due to someone forgetting to put braces around an if. The accuracy is debatable. Also, I would rename the functon prompt_ll to prompt_line. But I still believe that this is over-complicating. The O.P was writting a simple program, which isn't that simple anymore.
Jan 28, 2015 at 10:52 comment added 200_success @Ismael As for comments, I've written a detailed one for prompt_ll() where it is needed and a brief one for the enigmatic scanf("%*[^\n]"). Everything else is straightforward. You can infer the purpose of the two stanzas in main() from "Enter number of values to sum: " and the variable name total.
Jan 28, 2015 at 10:50 comment added 200_success @Ismael I don't discuss brace styles in reviews, to avoid unproductive controversy. Since you mention it, I've used Allman style to match the original code, despite my personal hatred of it for wasting space. I've therefore put return and break on the same line as a safe way to save three lines per condition.
Jan 28, 2015 at 10:30 comment added Ismael Miguel The review quality is amazing, but the suggested is too advanced for people who aren't really into C (I had 1 year of classes in C and have some troubles reading some parts of your code). Also, you don't follow good practices: if's without {}, spaces missing, usage of un-explicit variable names (looking at the variable n) and a huge lack of comments.
Jan 28, 2015 at 9:03 history answered 200_success CC BY-SA 3.0