c - warning: implicit declaration of function ‘printf’

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

I know alot of similar questions were asked before but i couldn't find something that would fix this warning i get:

MyIntFunctions.c:19:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] 

Occurs here:

void IntPrint (const void *key) {     printf("%d", *(int*)key); // line 19     printf("\t-->\t"); } 

and a similar warning:

MyStringFunctions.c:22:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]  void StringPrint (const void *key) {     printf("%s",(char*)key); //line 22     printf("\t-->\t"); } 

I really want to understand what is wrong so i won't do that again in the future.

回答1:

You need to include the appropriate header

#include 

If you're not sure which header a standard function is defined in, the function's man page will state this.



回答2:

You need to include a declaration of the printf() function.

#include 


回答3:

the warning or error of kind IMPLICIT DECLARATION is that the compiler is expecting a Function Declaration/Prototype..

It might either be a header file or your own function Declaration..



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!