Saturday, July 17, 2010

My First c++ program in Linux

Using any Text editor in Linux type the following program.For help refer



#include<iostream>using namespace std;
int main(){
cout<<"Hello world";

return 1;
}



To Compile type the following command
g++ sample.cpp -o sample
To run type the following command
./sample

If you don't have g++ compiler you will get err or as in screenshot.
then you may need to install g++ compiler.
For install become super user as in

To install type following command in terminal:

apt-get install g++

It will automatically download and install from Intern et.


Otherwise we can download
Code::Block IDE for compiling and running c++ program.


for that type following command as in screen shot:
apt-get install codeblocks




No comments:

Post a Comment