LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2003, 10:46 AM   #1
alexrm1x
LQ Newbie
 
Registered: Feb 2003
Location: Madrid, Spain
Distribution: Red Hat 8.0
Posts: 10

Rep: Reputation: 0
#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...
 
Old 03-05-2003, 10:57 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 03-05-2003, 11:22 AM   #3
dunkyb
Member
 
Registered: Nov 2002
Distribution: Debian testing.
Posts: 143

Rep: Reputation: 15
I think you will want

#include <iostream.h>

rather than #include <iostream>

hth

Duncan
 
Old 03-05-2003, 12:02 PM   #4
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
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
 
Old 03-05-2003, 12:53 PM   #5
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
#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
 
Old 03-05-2003, 12:55 PM   #6
dunkyb
Member
 
Registered: Nov 2002
Distribution: Debian testing.
Posts: 143

Rep: Reputation: 15
really? hmm, never knew #include <iostream> works nowadays, heh.

perhaps this only works with some new C++ compilers?!
 
Old 03-05-2003, 01:06 PM   #7
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
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
 
Old 03-09-2003, 03:41 PM   #8
JStew
Member
 
Registered: Oct 2002
Location: North Atlanta
Distribution: LFS
Posts: 229

Rep: Reputation: 30
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
 
Old 03-13-2003, 05:47 AM   #9
centr0
Member
 
Registered: Feb 2003
Location: Earth
Distribution: Slackware 9.1
Posts: 134

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

#include <iostream.h>
using namespace std;



just a thought =)
 
Old 03-14-2003, 10:04 AM   #10
kopernic
LQ Newbie
 
Registered: Mar 2003
Location: Wroclaw, Poland
Distribution: Slackware
Posts: 5

Rep: Reputation: 0
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
my iostream.h include won't work slinky2004 Programming 5 09-20-2005 12:37 AM
C++ iostream - getting "deprecated header" error jdruin Programming 3 09-28-2004 07:31 AM
GCC:- 'cout' is an undeclared function when #include <iostream> is included? caesius_01 Programming 5 04-04-2004 11:00 AM
"#include <iostream.h>" does not compile ambuj Linux - Software 7 01-28-2004 08:56 AM
g++ why cant i #include \<iostream\> ??? qwijibow Programming 4 10-03-2003 07:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration