In the case of scanf you need the specified format, unlike get. Thus, in gets you enter charecters, strings, numbers and spaces.
In the case of scanf , you enter the ends as soon as a space occurs.
But then in your example you use '% s', so neither gets() nor scanf() , so that the strings are valid pointers to arrays of sufficient length to hold the characters you send them. Therefore, this can lead to buffer overflows.
Tip: use fgets() , but it all depends on the use case
argentum47
source share