9

What is the difference between

#include <iostream.h>

and

#include <iostream>

?

Aioros
  • 4,373
  • 1
  • 18
  • 21

3 Answers3

18

Before C++ was even standardised, the I/O library was developed as <iostream.h>. However, that header has never been a standard C++ header. Some older compilers continued to distribute the <iostream> header also as <iostream.h>. Use <iostream> because it is guaranteed by the standard to exist.

It's worth noting that the only standard headers that end with .h are the C standard library headers. All C++ standard library headers do not end with .h.

Joseph Mansfield
  • 108,238
  • 20
  • 242
  • 324
  • 1
    During the transition period, there were compilers which delivered a `` which included `` (plus a number of `using`, so that you didn't need `std::`); there were others whose `` included `` (and the compiler was hacked to make `std::` the same as `::`). – James Kanze Mar 28 '13 at 11:47
  • Extra question about naming conventions: why it is named `` instead of ``? Or vice versa: why it is named `` instead of ``? – pmor Jun 23 '22 at 13:55
4

<iostream> is the usual header

<iostream.h> is the old header, not longer supported by some compilers

StepUp
  • 36,391
  • 15
  • 88
  • 148
0

It just depends on the name of the file provided by your toolchain. Some (old) compilers use .h files. Modern compilers usually use <iostream> (without the .h extension).

ecm
  • 2,583
  • 4
  • 21
  • 29
Claudio
  • 10,614
  • 4
  • 31
  • 71