原样报错信息为:
code0_hanshu.c: In function 'main':
code0_hanshu.c:4:2: warning: implicit declaration of function 'printWelcome' [-Wimplicit-function-declaration]
printWelcome();
^~~~~~~~~~~~
code0_hanshu.c: At top level:
code0_hanshu.c:7:6: warning: conflicting types for 'printWelcome'
void printWelcome(){
^~~~~~~~~~~~
code0_hanshu.c:4:2: note: previous implicit declaration of 'printWelcome' was here
printWelcome();
^~~~~~~~~~~~
解决办法:把下述main函数和printWelcome函数调换位置
int main()
{
printWelcome();
return 0;
}
void printWelcome(){
printf("----------------------\n");
printf("欢迎来到我的程序\n");
printf("----------------------\n");
}
调换位置,变成
void printWelcome(){
printf("----------------------\n");
printf("欢迎来到我的程序\n");
printf("----------------------\n");
}
int main()
{
printWelcome();
return 0;
}