LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 07-26-2009, 04:02 AM   #1
tqviet
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
a question about <iostream.h>


hi everbody,

I got a trouble when I compiled a file, coded in C++ language.

//The file was named by thu1.cpp is below:

#include<stdlib.h>
#include<iostream.h>

int main()
{
cout<< "hi everybody" << endl;
return 1;
}

In the terminal, I typed:

g++ -o thu1 thu1.cpp

and I got:

thu1.cpp:2:21: error: iostream.h: No such file or directory
thu1.cpp: In function ‘int main()’:
thu1.cpp:7: error: ‘cout’ was not declared in this scope
thu1.cpp:7: error: ‘endl’ was not declared in this scope


is there anyone help me ? Thank you.

PS: I use Debian-Linux.
 
Old 07-26-2009, 04:05 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

You're missing a package, that's obvious, most likely a development library. What distro are you using?

Kind regards,

Eric

Last edited by EricTRA; 07-26-2009 at 04:07 AM. Reason: Sunday typos
 
Old 07-26-2009, 04:08 AM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Per the C++ standard, you should be using "iostream", rather than "iostream.h". Also, for C headers (e.g. stdlib.h), you should drop the ".h" and prefix a "c" (so "stdlib.h" should become "cstdlib"). The problem of cout and endl not being declared in scope is due to the fact that they're defined in the std namespace. You need to either make the entire namespace available (by adding the statement "using namespace std;" below your include directives), include the specific objects you want to use (by including the statements "using std::cout;" and "using std::endl;" below your include directives) or fully qualify the cout and endl objects when you use them (e.g. "cout" should become "std::cout").

Edit: you don't actually make use of anything from stdlib.h/cstdlib, so why do you need to include it?

Edit: also, as this is a programming question, I've reported your thread to be moved to the programming forum.

Last edited by Nylex; 07-26-2009 at 04:10 AM.
 
Old 07-26-2009, 04:11 AM   #4
chigurh8
Member
 
Registered: Jul 2009
Distribution: Ubuntu, Gentoo
Posts: 102

Rep: Reputation: 18
Code:
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
    cout << "hello" << endl;
    return 0;
}
 
Old 07-26-2009, 04:12 AM   #5
chigurh8
Member
 
Registered: Jul 2009
Distribution: Ubuntu, Gentoo
Posts: 102

Rep: Reputation: 18
They're not missing anything, if written the same way it's written in their code, the exact same message will show up on mine. I'm not missing anything.
 
Old 07-26-2009, 07:38 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



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
g++ compiler and iostream.h BACTRATE Mandriva 5 07-26-2009 04:12 AM
what package is iostream.h in? bio71 Programming 3 09-11-2008 10:11 PM
Linux iostream vs Windows iostream davidguygc Programming 2 05-13-2007 09:13 PM
where is iostream invisibleghost Programming 2 10-24-2004 01:30 PM
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 12:53 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