All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
where in his code is he redirecting stdin to read from a file (unless you mean waiting for the EOF to to be hit via the terminal)? His objective was to get the junk out of the input buffer and clean it up. To that end he can read up to the '\n' after each input. Sure he could add the EOF to that as well to that macro, just seems like overkill IMHO.
I agree whole heartedly, the objective on my part wasn't to offer a quick fix and forget potential future issues, it was to generate compact code for the task at hand. Why declare a long, when a int with do?Getting code shorter by adding more bugs is not a good way to program
Warning: Opinions subject to change without notice
The C Library Reference Guide
Understand the fundamentals
Then have some more fun
The redirection can happen from the terminal/console/command prompt, not just the code.Originally Posted by caroundw5h
vart's point is about correctness. It might be a little paranoid, but the "overkill" will have no impact on performance anyway, and remains readable.Originally Posted by caroundw5h
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)