LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   #include <iostream> ERROR (https://www.linuxquestions.org/questions/programming-9/include-iostream-error-48417/)

alexrm1x 03-05-2003 10:46 AM

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

acid_kewpie 03-05-2003 10:57 AM

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.

dunkyb 03-05-2003 11:22 AM

I think you will want

#include <iostream.h>

rather than #include <iostream> :)

hth

Duncan

GtkUser 03-05-2003 12:02 PM

Code:

//standard header that uses a namespace called std
#include<iostream>

//standard declarations

using std::cout;
using std::endl;

int main() {
  cout << "Hello World" << endl;
  return 0;
}

g++ myprogram.cpp

nakkaya 03-05-2003 12:53 PM

#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

dunkyb 03-05-2003 12:55 PM

really? hmm, never knew #include <iostream> works nowadays, heh.

perhaps this only works with some new C++ compilers?!

nakkaya 03-05-2003 01:06 PM

Quote:

Originally posted by dunkyb
really? hmm, never knew #include <iostream> works nowadays, heh.

perhaps this only works with some new C++ compilers?!

cause in c++ programs using c code is permited but in c programs you cant use c++ code thats why new c++ compilers accept

JStew 03-09-2003 03:41 PM

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

centr0 03-13-2003 05:47 AM

very new to c++ myself. but you could also do this:

#include <iostream.h>
using namespace std;



just a thought =)

kopernic 03-14-2003 10:04 AM

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.