When we use gets() in C language then what does the compiler read whenever there comes a space? Ex : This " " is " " me. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

When we use gets() in C language then what does the compiler read whenever there comes a space? Ex : This " " is " " me.

This is related to C programming language. Your help is most appreciated 💚

14th May 2020, 11:04 AM
Raiyan
Raiyan - avatar
2 Answers
+ 4
i would not recommend using gets(). it is deprecated and insecure, if input is larger than string it overruns the buffer. Use fgets(s, sizeof(s), stdin) instead. fgets() also stops at newlines or EOF. Only difference is fgets() adds the newline to the string.
14th May 2020, 12:23 PM
Gen2oo
Gen2oo - avatar
+ 2
It reads it as a space and does not terminate unlike scanf(). You can write a code and run it on code playground to check the same.
14th May 2020, 12:02 PM
Avinesh
Avinesh - avatar