I am a complete beginner and have been taking youtube lessons on C. However I am stuck with a very basic error (I assume) and would appreciate an explanation of why I am getting this error:
I haven't tried any fixes as I have no clue - being a complete beginner.
#include <stdio.h>
#include <stdlib.h>
int main()
{
sayHi();
return 0;
}
void sayHi()
{
printf("Hello User");
}
f.c:6:5: error: implicit declaration of function 'sayHi' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sayHi(); ^ f.c:11:6: error: conflicting types for 'sayHi' void sayHi() ^ f.c:6:5: note: previous implicit declaration is here sayHi(); ^
void sayHi();()on a function declaration mean that it takes an unspecified number and type(s) of arguments. That's an obsolescent feature. To specify that the function takes no arguments (and get better compile-time checking), useint main(void)andvoid sayHi(void). (Note that in C++, empty parentheses do mean that the function takes no arguments.)