Ask coding questions

← Back to all posts
When I try to use the gest() function in C. I always get a warning "gets is invalid in C99"
Alexander1231

When I try to use the gets() function in C. I always get a warning "gets is invalid in C99"

Does anyone know why this is happening? Also how to fix the problem so I can use the function without any warnings?

The function works in this code but in other codes it doesn't work correctly

Voters
AashiqAhmed
xCatta
Alexander1231
Comments
hotnewtop
mwilki7

from what I'm getting from
https://stackoverflow.com/questions/49256131/why-is-implicit-declaration-of-gets-not-allowed-in-c99
gets was removed from the standard library and this error message was a notification for those with this in their legacy code to remove it

so it depends how old the compiler you're using is

you should use fscanf(file pointer, format string, argument1, argument2...) as a substitute

Example:

Output:

AashiqAhmed

use string.h

NathanWickenden

@AashiqAhmed
You still get the problem, it has nothing to do with the string.h library in c