Step1: Type the C/C++ source code using any text editor of your choice,
and save it with the extension .c for C programs and .cpp for C++ programs.
[linux c/cpp compiler, gcc, uses the extension of the source file to recognize the coding language].
Step2:To compile , assuming the source file name to be input_filename, type in the following command at the command prompt;
[root@localhost ~]# gcc -o output_filename input_filename
Note:- there is no space between -o and output_filename
Step3: To run the output file, type in the following command at the command prompt:
[root@localhost ~]# ./output_filename
END of Steps
--------------------------------
For example, to compile a source file named mysource.c, to produce an outputfile named myout, and to execute it, we can use the following steps:
[root@localhost ~]# gcc -o myout mysource.c
[root@localhost ~]# ./myout
.........................................................
No comments:
Post a Comment