LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-08-2010, 07:00 PM   #1
FelipeGamma
LQ Newbie
 
Registered: Jun 2010
Location: Colombia
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
ERROR: iostream.h: No such file or directory...‘cin’ was not declared in this scope



I create a simple code for add two number:
Code:
#include<iostream.h>
#include<stdio.h>

main()
{
int num1, num2, sum;
cout<< "input the first number: ";
cin>> num1;
cout<< "input the second number: ";
cin>> num2;
sum= num1+num2;
cout<< "The result is: ";
cout<< sum;
}
But when I compile the code:
Code:
$ c++ sum.c
The console shows the next error:
Quote:
suma.c:1:21: error: iostream.h: No such file or directory
suma.c:3:18: error: stlib.h: No such file or directory
suma.c: In function ‘int main()’:
suma.c:8: error: ‘cout’ was not declared in this scope
suma.c:9: error: ‘cin’ was not declared in this scope
I search the answer to my problem in various forums but I can't solve the problem.
I think that is due to I need some package or that I don't install the necessary libraries.

Thanks,

 
Old 06-08-2010, 07:09 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

"iostream.h" is an anachronism.

Modern C++ programs should use "#include <iostream>" instead.

Here's an example:
Code:
#include <iostream>
 
using namespace std;
 
int 
main(int argc, char* argv[])
{
  cout << "Hello world" << endl;
  return 0;
}
'Hope that helps .. PSM

PS:
Of course, maybe you just didn't install the complete development package.

For Redhat or Centos, for example, you'd run something like:
Quote:
yum install gcc gcc-c++ make autoconf automake gawk binutils
for Ubuntu, an equivalent command might be:
Quote:
sudo aptitude install build-essential

Last edited by paulsm4; 06-08-2010 at 07:13 PM.
 
Old 06-08-2010, 08:02 PM   #3
FelipeGamma
LQ Newbie
 
Registered: Jun 2010
Location: Colombia
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks paulsm4...
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem compiling (error: ‘strcmp’ was not declared in this scope) beboppinbobby Linux - Newbie 4 12-19-2009 01:33 AM
aria2, ‘assert’ was not declared in this scope , compiler error adityasharma Linux - Newbie 4 07-31-2009 05:51 AM
Compiling tesseract-2.03: error: ‘INT32’ was not declared in this scope J_Szucs Linux - Software 10 03-05-2009 02:35 PM
/ArgParser.cpp:207: error: 'atoi' was not declared in this scope Jane2008 Linux - Newbie 2 11-07-2008 09:23 AM
Error Prompt - 'Execute_command was not declared in this scope. Please help! thhuang Linux - Newbie 1 11-05-2007 12:38 AM


All times are GMT -5. The time now is 11:03 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration