1. while reading from stdin using scanf(), newline is not read however it is ready to be read from very next scanf() call. to avoid this use %*c when reading. %*c will read newline from buffer and discard it.
int nLine;
scanf("%d%*c", &nLine); //after reading character in c, newline is read and discarded. and therefore next scanf will read from stdin
No comments:
Post a Comment