+ 4

Gets in c

Playground/file0.c: In function 'main': ./Playground/file0.c:6:5: warning: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 6 | gets(a); | ^~~~ | fgets ../Playground/: /tmp/cciNin95.o: in function `main': file0.c:(.text+0x15): warning: the `gets' function is dangerous and should not be used. Can anyone help me get out of this error that I'm getting when gets function is used

20th Jul 2020, 11:44 AM
Usha Sri
Usha Sri - avatar
3 Antworten
+ 3
Usha Sri that's because gets() has been removed from C standards because of its dangerous behaviour of overflowing the buffer. Use fgets() as an alternative of it. Learn about fgets() and how to use it here👇 https://www.educative.io/edpresso/how-to-use-the-fgets-function-in-c
20th Jul 2020, 11:57 AM
Arsenic
Arsenic - avatar
+ 2
use fgets(array, size , stdin ) function eg: Int array[100]; fgets (array, 100, stdin); /** this statement will take 100 character input untill enter or new line is given **/
10th Aug 2020, 2:47 AM
mohit kumar
mohit kumar - avatar
20th Jul 2020, 12:09 PM
Vasile Eftodii
Vasile Eftodii - avatar