Compiler cannot find iostream

As a complete beginner I have been trying to "get into" C programming. While following a tutorial the following code failed to compile. Compiler reported it did not find iostream(.h) I have tried a number of IDEs and MinGW and Borland BCC55 compilers - same result.

1
2
3
4
5
6
7
8
9
10
  #include  <iostream.h>
using namespace std;

int main () {

   cout << "Hello world";
   return 0;

}
(1) Remove the ".h"
(2) Find a (considerably) more up-to-date tutorial.

My (personal) experience is that the one on this site is an excellent one for beginners.
> As a complete beginner I have been trying to "get into" C programming.
Your first program is a C++ program.
Be clear on what language you want to learn.

Their common heritage and superficial similarity means if you try "C/C++", you end up making a mess of both.
Hello johnOk9,

It is my understand that "iostream.h" was the early header file when C++ first started. I believe the 1998 standards made changes that dropped the ".h" from the header files.

These days the newer compilers may not have some of the old C header files or the old C++ header files ending in ".h" as they have phased out.

This does not mean that C header files can not be used in a C++ program. Some C header files have a C++ version like "cstdlib" or "ctime" If they are available you should uses these over the old C header files. For a list check out the reference section with the link in the upper left corner. I also find this to be a good reference link https://en.cppreference.com/w/

As far as reading a tutorial you can try https://www.learncpp.com/ I have found this to very good and it is kept up to date.

Andy
we need to be precise.
iostream is not a C header, it is c++. You cannot use it in C.
C uses stdio.h and printf instead of cout


following a tutorial...compiler cannot find iostream

That tutorial is seriously ancient. Including <iostream.h> is at least 20 (or so) years out of date, so most compilers created since 1998 will use <iostream> instead.

There is an online tutorial here at CPlusPlus (not kept updated, C++11 with some C++14):
http://www.cplusplus.com/doc/tutorial/

Another online tutorial that is (mostly) kept up to date:
https://www.learncpp.com/

No tutorial will cover the entire C++ language. The most any can do is give a beginner a grasp of the language basics. Especially as newer standards become approved. The current standard is C++20.

A reference site for C and C++ is https://en.cppreference.com/w/

It is NOT a tutorial.
Good day,

I did post here again, but it seems to have disappeared. I would like to say thanks - the problem was I was using sections of code interchangeably - problem solved. Thanks again

Cheers JK.
Topic archived. No new replies allowed.