I get this weird warning message in Visual Studio Code the whole time and have no idea what else I should change.
Message:
warning: implicit declaration of function 'showMenu' [-Wimplicit-function-declaration]
This is the code:
#include <stdio.h>
int main() {
showMenu();
return 0;
}
int showMenu() {
printf(" Herzlich willkommen n");
printf("(0) Telefonnummern anzeigenn");
printf("(1) Neue Nummer hinzufügenn");
printf("nn");
return 0;
}
Hope someone can help me.
greetings
" ; if ($?) { gcc Adressbuch.c -o Adressbuch } ; if ($?) { .Adressbuch }
Adressbuch.c: In function 'main':
Adressbuch.c:5:4: warning: implicit declaration of function 'showMenu' [-Wimplicit-function-declaration]
showMenu();
^~~~~~~~
Herzlich willkommen
(0) Telefonnummern anzeigen
(1) Neue Nummer hinzuf├╝gen
I get the results, but with the error message in it.
2
Answers
The function shall be declared before its usage as for example before main
Pay attention to that the return type
int
of the function does not make a great sense. You could declare it likeJust add a prototype to your
showMenu
function before the main.Example