@CyberDemon - if this lesson is about
scanf()
that is fine -- it is one of the, if not the, most misused input function by new C programmers. It has a number of pitfalls that unless you know the manual (man page) cold, are likely to bite you. Spend an hour with
man 3 scanf and it will save you 100 hours of grief. That said, if you are not required to use
scanf()
then generally all user-input should be taken with
fgets()
using a buffer of sufficient size (don't skimp 1024 is fine). Trim the
'\n'
with
buffer[strcspn(buffer,"\n")]=0;
—
David C. Rankin 50 secs ago