Code: #include<stdio.h> int main() { void print(); } void print() { printf("\n in the function \n "); } IN THE ABOVE CODE 1. if i write void in front of print function call in main it is being compiled successfully but their is no output 2. When i omit void from it then their is a warning generated simple_function.c:8:6: warning: conflicting types for ‘print’ [enabled by default] void print() ^ simple_function.c:5:2: note: previous implicit declaration of ‘print’ was here print(); ^
When you don't prototype a function, C sometimes (and in your case does) give you an "automatic" prototype, which is "int print();" You then go on to "redefine" print as returning a void, hence the warning. The reason you get no output when you put a void in front of the print in main is that this changes the statement from a function call to a function prototype. Solution: Move the print function above main, or prototype it correctly.