mugurumakensei said:I think this is far more fascinating. It shows a lot of the pitfalls that developers unintentionally fall into when working with languages like C/C++.
I see what you mean. It's funny how tricky these things can get (I had to look at your changes for 3 minutes by eye and the output to even follow the changes you had made).
At the end of the day, you get a lot of programmers who throw C or C++ down on their resume as a known language; when, sometimes, they only know maybe Java and C# and figure "Oh, what the hell, C/C++ can't be THAT different from what I know." I would call programs like the original I posted and your version to be, sort of, a litmus test of whether or not these people really know what they claim they know.
At the end of the day, people are probably more interested in asking about linked lists, or avl trees, whatever -- but it's stuff like these smaller programs where the heavy lifting appears in one line that really tests comprehension.