The goal is for the function to say hi ("Hello User"), but it keeps telling me that my sayHi function is invalid. I'm not sure why.
#include <stdio.h>
#include <stdlib.h>
int main(){
sayHi();
return 0;
}
void sayHi ()
{
printf ("Hello User");
}
CodePudding user response:
You can either try this
#include <stdio.h>
#include <stdlib.h>
void sayHi();
int main() {
sayHi();
return 0;
}
void sayHi() {
printf ("Hello User");
}
or this
#include <stdio.h>
#include <stdlib.h>
void sayHi() {
printf ("Hello User");
}
int main() {
sayHi();
return 0;
}
CodePudding user response:
You need to either forward declare the function, or put the definition before main()
, so that the compiler knows about the function being called.