我理解"隐式声明"通常意味着在调用函数之前必须将函数置于程序的顶部,或者我需要声明原型.
但是,gets应该在stdio.h文件中(我已经包含在内).
有没有什么办法解决这一问题?
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char ch, file_name[25];
FILE *fp;
printf("Enter the name of file you wish to see\n");
gets(file_name);
fp = fopen(file_name,"r"); // read mode
if( fp == NULL )
{
perror("Error while opening the file.\n");
exit(EXIT_FAILURE);
}
}
Run Code Online (Sandbox Code Playgroud)