DEV Community

IshidaKeisuke
IshidaKeisuke

Posted on

C Language Mystery

int main() {
    printf("hello world\n");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

When I run the above code, I get the following result. but the hello world result was output. Could you please tell me why?

hoge.c:2:5: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    printf("hello world\n");
    ^
hoge.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 error generated.
hello world
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
giorgione_da_marino profile image
Giorgio Bovenzi

You are missing the library that contains that function. As states the error output you need to have the line โ€œ#include โ€ at the beginning of the code file.

Collapse
 
martins_ngene profile image
Martins Ngene

Hello, what code ide are you using? Also you can ask this question on stackoverflow and upload screenshots of the error so you can get help.