No, seriously, what do "<stdio.h>" and "<conio.h>" mean.....? :\
stdio.h is a C header file containing the function definitions for input and output. So it contains I/O functions like printf, scanf etc. which are all part of standard C.
In order to use any of the functions defined in stdio.h, you must first #include the header file. The #include statement in C/C++ is analogous to the import statement in Python.
On the other hand, conio.h is a non-standard header file used by 20 year old Borland compilers,. It contains some proprietary extensions that Borland added for doing various things in the console (moving the cursor with gotoxy(), changing text color etc). The use of this header is specific to old Borland compilers for Windows. It is not portable and cannot be used under Linux (because it doesn't exist).
If you try compiling the code you posted under gcc on Linux, it would not compile at all. It would bomb out almost immediately, complaining that conio.h could not be found. There is another problem in the code you posted, more on that in a bit!
There are a large number of C (and even C++) articles and 'tutorials' online which #include conio.h. But, as mentioned; it is only available to ancient, outdated Borland compilers (which again, are only available for Windows). For some reason a lot of academic institutes in places like India and Pakistan are still using these woefully outdated compilers.... I really don't know why. Surely it would make sense to allow their students to use a decent free compiler like gcc, which is up to date, is standards compliant, is available on multiple platforms and will allow the students to learn more modern C and C++ practices! But perhaps it is the teachers/faculty in these institutions who are unwilling to change and are happy to be teaching their students outdated practices!
Either way, because of this there seems to be a proliferation of articles, tutorials and questions on forums from students who are still being subjected to these old C/C++ compilers!
Another thing about these old compilers is that they predate the formalisation of the C and C++ ISO standards. So lots of these Borland specific tutorials allow outdated, non-standard things like main functions that return void, or have no return value at all (like the example you posted!). The C and C++ standards state that the main() function must
always return an int.
So a more correct example of hello world in C would be:
Code:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
If your program requires command line arguments, the following are also acceptable, standard compliant signatures for the main function:
Code:
int main(int argc, char *argv[])
or
Code:
int main(int argc, char **argv)
Both of the above are equivalent!
Basically, if you see a C or C++ tutorial that contains "conio.h" or has a signature for main that is anything other than one of the three int signatures you can see in the above snippets, then avoid it like the plague as it is outdated!
I'm getting tired, so I'm going to shut up now!
