main.c: In function 'subReplace': main.c:127:5: warning: implicit declaration of function 'strlnsertSub' [-Wimplicit-function-declaration] strlnsertSub(s,r,pos); ^ main.c: In function 'main': main.c:163:5: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration] gets(s1); ^ /tmp/ccXuF9gp.o: In function `main': main.c:(.text.startup+0xb5): warning: the `gets' function is dangerous and should not be used. /tmp/ccXuF9gp.o: In function `subReplace': main.c:(.text+0x4a5): undefined reference to `strlnsertSub' collect2: error: ld returned 1 exit status
时间: 2023-06-08 15:07:38 浏览: 98
对于您的问题,我可以告诉您,在您的代码中存在一些隐式声明的函数,这可能导致编译器警告和错误。特别地,函数'strlnsertSub'在你的代码中没有被正确声明,导致出现undefined reference错误。此外,函数'gets'也是危险的,不建议使用它,可以使用fgets代替。如果您需要更多帮助,请提供您的完整代码,我可以为您提供更具体的建议。
相关问题
main.c:21:2: warning: implicit declaration of function ‘wait’ [-Wimplicit-function-declaration]
这个警告是因为在您的代码中,使用了一个未声明的函数`wait`。C语言要求在使用函数之前先进行声明,以告诉编译器函数的返回类型和参数类型。如果您确实想要使用`wait`函数,需要在代码中添加一个函数声明,比如`int wait(int *status)`。
另外,您还可以包含头文件`<sys/wait.h>`,该头文件中包含了`wait`函数的声明。您可以将以下代码行添加到您的代码中:
```c
#include <sys/wait.h>
```
这样就可以解决这个警告问题了。
main.c:9:2: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
这个警告是由于在代码中使用了未声明的函数"sleep"导致的。在C语言中,如果使用一个函数而没有提供函数的声明或者头文件的包含,编译器会给出一个隐式声明的警告。
要解决这个警告,你可以在代码文件顶部添加以下头文件的包含:
```c
#include <unistd.h>
```
这个头文件中包含了对sleep函数的声明。这样编译器就可以正确识别和使用sleep函数了。