PDA

View Full Version : [SOLVED] trouble in compiling cpp programs using g++



hellofriendz
December 20th, 2009, 06:08 PM
hey guys plz do help me... i'm in real trouble.....
always getting the error : No such file or directory
when i compile a simple prgm....

PROGRAM gedit abc.cpp#include<iostream.h>
main()
{
cout<<"Hello\n";
}

COMPILATION STEP

g++ abc.cpp

ERRORS

abc.cpp:1:21: error: iostream.h: No such file or directory
abc.cpp: In function ‘int main()’:
abc.cpp:4: error: ‘cout’ was not declared in this scope
:(:confused:

cpplinux
December 20th, 2009, 06:18 PM
1. include <iostream> instead of <iostream.h>
2. add using namespace std; before the line of 'int main()'.

hellofriendz
December 20th, 2009, 07:59 PM
OH MY... it worked...!:P:KS
thanks a lot buddy....
but why is it like that....???
i mean in college i didnt need to include namespace std....
is there a way to avoid that and proceed in the normal way???:-k

anyways thanks a lot my friend....=D>