scanf(3) returns (see its man page):
1. > 0: The number of items scanned successfully.
2. = 0: There is more input but the next character to be scanned doesn't match syntactically the first input type.
3.
EOF: Any error or end-of-file occurred.
So to get all input variables being well initialized you may better run a positive test of
scanf(3) return value.
If you want to get input into more than one variable from only one
scanf(3) expression, a positive test may be inevitable to avoid running out of sync with your input data stream.
@jumper007: Using is.good() does only work well having initially synchronized both stdin method (C-stdio and C++-streaming) because they use different buffers for the same stream. See
http://www.cplusplus.com/reference/ios/ios_base/sync_with_stdio/. But mixing both methods usually makes sense only if you're using libraries which use another method than your preferred one.
@anirudh sn: Posix stdio doesn't distinguish between console input or those from other files. There's also no
<conio.h> available nor needed when using Posix stdio. May be you need it to get those non-Posix
getch() function prototype? I've never seen it before.