I am learing C and would like to know is it possible to replace function call with function declaration ..like in below programme
main() {
void show();
getch();
}
void show() {
clrscr();
printf("Tendulkar is best batsman ever");
}
here in main am declaraing show function and not calling it anywhere but still
printf("Tendulkar is best batsman ever");
is getting executed.why is it so??
And one more thing guys when i run below programme on turbo c++ is giving me error but on gcc its work fine
main()
{
show();
}
void show()
{
printf("Tendulkar is best batsman ever");
}
expected
Answer:
Compier error: Type mismatch in redeclaration of show.
Explanation:
When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error.