Why do we use the header file in C. #include<stdio.h> void main() { printf("Hello"); } OR void main() { printf("Hello"); } both returns same output then why do we use #include<stdio.h>
In the situation you list, there's no real benefit unless you have strict rules on. However, if you were to try to use, say, the open or stat routines, you wouldn't get them to compile without the header file included.
In this case, you don't need to include header. But in the complex source code, you will include header.
Your compiler is just being kind and assuming that printf would be in the standard library and not bugging you about it. Turn all warnings on and you will notice that the stdio.h header missing error will be reported.
but it requires header files for a c++ program, i mean C++ shows errors but C dont show any errors and the number of lines complied are 400+ in C++ program but in C on few line. like for the above case it would be 4