Reputation: 9
I am talking input using gets()
function. So, I want to check where string ends. But NULL
is not inserted at the end of the string as it is inserted by using scanf()
. So how can I do this?
Upvotes: 0
Views: 2956
Reputation: 249582
gets()
absolutely does insert a null terminator. However, please note that gets()
is deprecated and should not be used at all. Use fgets()
instead, as it avoids buffer overrun vulnerabilities.
To use fgets
on standard input:
char buffer[256]
fgets(buffer, sizeof(buffer), stdin);
Upvotes: 8