+ 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
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
+ 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 **/