Thanks a lot:-))
Printable View
Thanks a lot:-))
Thanks for commenting on my post. It looks like scanf() only retains the new-line character if the input being read in is of type char. Is that correct?
Yes. The newline is skipped over as whitespace, when scanf() is expecting a number. It can't do that for char's however, since a newline is really just two char's, put together (for Windows and DOS, at least):
10 Carriage return + 13 Line feed
I prefer the term "accepts as input" rather than "retains it", however - since scanf() doesn't retain anything. It either accepts and assigns the input, or it does not.
It's like Yoda: "Do or do not" :)
Understood. Thanks a lot:-))