Sunday, March 28, 2010

gets vs scanf for reading string

gets(): Reads characters from stdin and stores them as a string into str until a newline character ('\n') or the End-of-File is reached.


scanf(): This function ignores whitespace character, newline, tab characters encountered before the next non-whitespace character.

strlen() does not include the \0 character.

No comments:

Post a Comment