gokul
gokul

Reputation: 29

c++ simple program error

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?

Upvotes: 0

Views: 3887

Answers (7)

Sebastian Mach
Sebastian Mach

Reputation: 39089

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.

Upvotes: 0

Mr Lister
Mr Lister

Reputation: 46559

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.

Upvotes: 0

Rituparna Kashyap
Rituparna Kashyap

Reputation: 1507

Include iostream instead of iostream.h

Upvotes: 1

lucian.pantelimon
lucian.pantelimon

Reputation: 3669

This is just a warning.

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

Upvotes: 0

IndieProgrammer
IndieProgrammer

Reputation: 587

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

Upvotes: 1

Kerrek SB
Kerrek SB

Reputation: 476980

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.)

Upvotes: 1

orlp
orlp

Reputation: 117681

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;
}

Upvotes: 6

Related Questions