#include <iostream> ERROR
Hi,
I'm still new to C and C++ programming. I'm including #include <iostream> in my programs for using std::cin, cout, endl and stuff like that... When I generate objet code with command: gcc -E first.c -ofirst.txt , I receive the error: "first.c:2:22: iostream: No such file or directory". I searched in my HD and I've these files in /usr/include/c++/3.2 Is this a path problem? How can I handle it? My programs are edited in directory "/Programas". Many thanks! alexrm1x Spain... everything under the Sun... |
iostream is for C++ programming, not C. you have written a c example (of sorts) with an extension of .c (recognised as a c file) and tried to compile it with gcc (a c compiler), yet are trying to use functions only existant in C++. mixing lanaguges is a bad bad idea.
|
I think you will want
#include <iostream.h> rather than #include <iostream> :) hth Duncan |
Code:
//standard header that uses a namespace called std |
#include <iostream.h> this is old c style
#include <iostream> new c++ style you can use both styles in c++ programmes but you cant use the second one on c programs |
really? hmm, never knew #include <iostream> works nowadays, heh.
perhaps this only works with some new C++ compilers?! |
Quote:
|
the following:
#include <iostream> using namespace std; this will allow you to use all of the iostream functions and statements without having to do std::cout etc.. and others |
very new to c++ myself. but you could also do this:
#include <iostream.h> using namespace std; just a thought =) |
strange... any idea ??
With added #include <iostream.h> and gcc
In file included from /usr/include/c++/3.2/backward/iostream.h:31, from io.cpp:1: /usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #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 <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header ...etc With c++ compiler /usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #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 <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. And with #include <iostream> and c++ everything went smoothly with no errors/warnings... That's all for now... |
All times are GMT -5. The time now is 08:02 AM. |