when to use iostream and iostream.h? similarly when to use int main and void main? what is difference between these? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

when to use iostream and iostream.h? similarly when to use int main and void main? what is difference between these?

25th Sep 2016, 6:18 PM
Astha
3 Answers
+ 1
You should almost never use "void main". The fact that it works at all is compiler specific and could cause problems when you run your program on a different system. iostream.h is the actual filename of the header file iostream. If you want your program to use the iostream library, you have to put #include <iostream.h>. If you put #include <iostream> without the .h, the compiler will not know what file is being referenced.
26th Sep 2016, 2:34 AM
Ryne
Ryne - avatar
0
Thanks Ryne. But on this site, <iostream> has been used everywhere. Why not <iostream.h> ?
26th Sep 2016, 4:21 AM
Astha
0
Sorry. <iostream> is ok for c++ and <iostream.h> is c. I always forget that the course is c++ on this site.
28th Sep 2016, 12:36 AM
Ryne
Ryne - avatar