I'm getting implicit declaration of function error in C. What is the reason for this?

Viewed 9
#include <stdio.h>
#include <stdlib.h>

int main(){

    sayHi();
    return 0;

}
void sayHi(){
    printf("Hello user");

When I type this. I get these errors

prog.c: In function ‘main’:
prog.c:7:5: warning: implicit declaration of function ‘sayHi’ [-Wimplicit-function-declaration]
    7 |     sayHi();
      |     ^~~~~
prog.c: At top level:
prog.c:16:6: warning: conflicting types for ‘sayHi’
   16 | void sayHi(){
      |      ^~~~~
prog.c:7:5: note: previous implicit declaration of ‘sayHi’ was here
    7 |     sayHi();
      |     ^~~~~
prog.c: In function ‘sayHi’:
prog.c:17:5: error: expected declaration or statement at end of input
   17 |     printf("Hello user");
      |     ^~~~~~

Why am I getting this error?

0 Answers
Related