Linux uses gcc compiler for compiling C programs and g++ for C++ programs.If you are unable to compile or run C and C++ program in Linux terminal then follow these steps.
(1) Using vi or vim editor create a C file(should be named with .c extension) and do the same for the C++ program(should be saved as .cpp)
(2) Then compile C program using following command
$gcc -o destfile sourcefile
for example if you have created a file first.c then
$gcc -o first first.c
(1) Using vi or vim editor create a C file(should be named with .c extension) and do the same for the C++ program(should be saved as .cpp)
(2) Then compile C program using following command
$gcc -o destfile sourcefile
for example if you have created a file first.c then
$gcc -o first first.c
Your compiled file will be created as first.To run this file
$./first
For C++ use g++ command with same extensions.
If you are unable to compile or run C or C++ program OR you are getting error compiling C or C++ file that means you have not installed compiler gcc and g++ in your operating system.
Follow the steps for C:
$su
$yum install gcc
For C++
$yum install g++
This will install compilers for C and C++ for linux.I hope this will help you.
$./first
For C++ use g++ command with same extensions.
If you are unable to compile or run C or C++ program OR you are getting error compiling C or C++ file that means you have not installed compiler gcc and g++ in your operating system.
Follow the steps for C:
$su
$yum install gcc
For C++
$yum install g++
This will install compilers for C and C++ for linux.I hope this will help you.