PDA

View Full Version : printf - get rid of warning



xlinuks
January 24th, 2008, 08:35 PM
Hi,
when compiling this C code, gcc does compile the code but issues warnings


#include <string.h>

main() {
char str[] = "Hi there\n";
printf( "%s", str );
}



test.c: In function ‘main’:
test.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

Does anyone know how to get rid of them, am i doing something wrong?

Oh nevermind, I had to include <stdio.h>

fyplinux
January 26th, 2008, 12:30 AM
Normally, if you get the message"incompatible implicit declaration of built-in function ‘printf’", you need to #include some external head files, or declare your own functions.

you can get rid of this message by

#include<stdio.h>