Monday, August 3, 2009

How to write C, C++ Programs in Linux

Open any text editor

start typing your program

Save it on any path

go to the path and use gcc command
Note : gcc is the compiler used for compiling c, c++ programs in linux

on the command prompt type as following
gcc filename

the output by default is a.out which is created on the same place

if you want to change the out put file your desired name type following

gcc name_of_output_file name_of_input file
Note : there are spaces used in between gcc and output file name and input file name respectively

after compiling the file as output file you can directly execute the file as follows

./name_of_output_file
Note: remember .(dot) and /(forward slash) are used to run any executable file in Linux so they are essential

No comments: