my compiler cant find the iostream.h

Asked by yonatan zemah

i try to run some codes with the include <iostream.h> and the compailer cant find the file
i reinstall the g++ but it dosent help me also i try to find/locate the file and he dont exist
i cant find a way to download it from firefox what can i do ?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Michael Basse (michael-alpha-unix) said :
#1

its a good idea to install build-essential if you want to code. this package will pull usefull and important stuff (not all needed) but you dont have to search stuff you need which is missing at the moment

sudo apt-get install build-essential

Revision history for this message
yonatan zemah (yonatan-zemah) said :
#2

i already installed the build-essential thanks anyway

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#3

Seems you need to install the mingw32 package

Revision history for this message
mycae (mycae) said :
#4

This has nothing to do with build-essential or mingw32.

You have specified the wrong header. C++ headers, such as iostream do not have a .h extention.

so you want

#include <iostream>

not
#include <iostream.h>

Note that similarly, for C headers used in c++, these have "c" prepended to the name, and no .h suffix

so in c you might write:

#include <math.h>

but in c++ you write:

#include <cmath>

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#5

Actually, the original C headers are still supported in C++. It's the C-style C++ headers (such as <iostream.h>) that are not supported anymore (except on a few compilers, such as Microsoft Visual C++). Please note that using these headers is not valid C++ by the current C++ standard, so you should consider avoiding them even when using compilers that do support them for backward compatibility.

There is actually a difference between including <cmath> and <math.h> (and for other C headers, such as cstdlib/stdlib.h, cstdio/stdio.h, and so forth). Symbol names defined in these headers (such as names of functions) are defined in the std namespace in the <cX> versions, but in the global namespace in the <X.h> versions.

See https://answers.launchpad.net/ubuntu/+source/gcc-defaults/+question/143691 and posts #1 and #6 in https://answers.launchpad.net/ubuntu/+source/gcc-defaults/+question/143699 for details.

Can you help with this problem?

Provide an answer of your own, or ask yonatan zemah for more information if necessary.

To post a message you must log in.