The reason for reading not all input values is sourced by using
gets - C++ Reference
] reads until a new line character has been read without storing the newline character in the read buffer.
scanf - C++ Reference
] skips leading white spaces (including new line characters) and reads until the format does not match anymore. That usually lets new line characters in the system input buffer.
So there will be an unread new line character after calling
. When calling
aftwerwards, that will read the new line character and stop resulting in an empty string in the passed buffer.
To avoid such problems, don't use both functions or ensure that new line characters are skipped before calling
A common solution is to use fgets - C++ Reference
] for all read operations (instead of
as alredy suggested). For inputs that are not strings use conversion functions like
for multiple parameters on one line.