0

I have created a file called untitled1.cpp in dev-cpp with the following script:

#include <iostream.h>
using namespace std;
int main(){
    cout << "C++";
    return 0;
}

But the compiler shows errors like:

1 F:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31,
from F:\Dev-Cpp\Untitled1.cpp In file included from include/c++/3.4.2/backward/iostream.h:31, from F:\Dev-Cpp\Untitled1.cpp 32:2 F:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.

What is the error that I have? How do I fix it?

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
gokul
  • 29
  • 1
  • 5
  • 1
    possible duplicate of [Where to get iostream.h](http://stackoverflow.com/questions/3698267/where-to-get-iostream-h) – Anonymous Apr 05 '12 at 07:32
  • Those are use warning. Still it is complied. – Rituparna Kashyap Apr 05 '12 at 07:35
  • I always find it funny when "simple errors" are presented. If they are "simple" to you, why can't you fix it yourself? – Sebastian Mach Apr 05 '12 at 07:36
  • @phresnel Gokul might have meant that the program was simple, not the error. – Mr Lister Apr 05 '12 at 07:38
  • 2
    I think it's funnier that the warning message tells you exactly what's wrong... – Andreas Brinck Apr 05 '12 at 07:39
  • @AndreasBrinck Yeah, but in a very roundabout way. If I got a warning that long, I might scratch my head too! – Mr Lister Apr 05 '12 at 07:41
  • 1
    The first thing it says is "This file includes at least one deprecated or antiquated header" – Andreas Brinck Apr 05 '12 at 07:42
  • @MrLister: Admittedly the poster might have thought this. My interpretation was "simple program-error" (and that's a common pattern on forums). However, I agree on Andreas that actually reading error messages is a Good Thing. While me may [not expect users to read stuff](http://www.joelonsoftware.com/uibook/chapters/fog0000000062.html), we may do so from programmers. – Sebastian Mach Apr 05 '12 at 08:41
  • @phresnel I know, I also wrote that in my answer ;) – Mr Lister Apr 05 '12 at 08:43

7 Answers7

6

In C++ you import the standard library without using the .h suffix.

#include <iostream>

So your fixed example:

#include <iostream>

int main(int argc, char **argv) {
    std::cout << "C++";
    return 0;
}
orlp
  • 112,504
  • 36
  • 218
  • 315
1

Your code is not standard C++. You should say #include <iostream> (no ".h"!). Whatever source you have been learning this from is about 25 years out of date, and you should consider getting some more modern material.

(The "iostreams.h" header was part of a very early non-standard library in the early 1990s, and so it's being kept around for "compatibility" reasons, or to catch very inert programmers and give them a helpful hint.)

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
  • @MrLister: Yes. C programmers of the style "I've written that C-with-classes thing when you were still in your diapers, and I'm not going to write it any differently now." – Kerrek SB Apr 05 '12 at 07:46
  • Ah, OK. I thought you might mean "inept", sorry. – Mr Lister Apr 05 '12 at 07:49
1

Use header file as #include<iostream> instead of #include<iostream.h>

IndieProgrammer
  • 579
  • 1
  • 5
  • 14
1

Include iostream instead of iostream.h

Rituparna Kashyap
  • 1,497
  • 13
  • 19
0

It says that the header, in this case, iostream.h is deprecated or antiquated. (You only have one header, so that's the one! Just read the error message!)

So you'll have to use iostream, not iostream.h.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
0

This is just a warning.

I think that you could try to include iostream instead of iostream.h in order to fix it.

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
0

You've posted the reason in your question already!

This file includes at least one deprecated or antiquated header.

The real question should therefore be: "Which one is antiquated, how do I replace it?", not "What's the error". Answer: Use <iostream>. The <*.h> versions are pre-standard, legacy headers.

So: Read error messages, people.

Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130