implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration] gets(str);
时间: 2023-11-15 11:34:57 浏览: 134
implicit declaration of function(解决方案).md
This warning message is indicating that the function `gets()` has been used without being declared explicitly in the code. This could cause issues during compilation or execution of the program.
The warning message is suggesting to use the function `fgets()` instead, which is a safer alternative to `gets()`. `fgets()` takes an additional parameter specifying the maximum number of characters to read, which helps prevent buffer overflows.
To fix this warning, replace the line `gets(str);` with `fgets(str, sizeof(str), stdin);` where `str` is the character array to store the input and `stdin` is the standard input stream. This will ensure that the input is read safely and without any buffer overflows.
阅读全文