@Giannis, yes and no, and it brings up another host of problems on its own. First the
"%s"
conversion specifier will stop reading when it encounters the first
whitespace. Second, unless you provide the
field-width modifier, it provides no check on the number of characters read (similar to the issue with
gets
). So if your buffer is
256-chars
, you must provide a maximum
field-width of
"%255s"
to limit what
scanf
will read to what fits in your buffer. Lastly,
scanf
is full of pitfalls for new programmers due to what remains in
stdin
after a
matching-failure. —
David C. Rankin 54 secs ago