C & C++ On Unix
Till a few years back, it was really difficult to obtain a free version of a compiler to run on ones machine to learn C or C++. And one had to resort to using a commercial compiler either by paying money and buying a licence or using a pirated copy of the same. Couple of years back, Borland C was considered to be the best compiler in the market for windows platform but later Microsoft’s Visual-C usurped it to take the most popular position. Then GNU/Linux got wider acceptance and the rest as they say is history. Most GNU/Linux distributions ship with the gcc suite of compilers. GCC stands for GNU Compiler Collection. And it contains compilers for various languages such as C,C++,Java and so on.
To check which version of gcc is installed on unix computer.
$ gcc -v
Example:- Basic c program to print “Hello Genowin Technologies”
int main(int argc, char** argv)
printf(“Hello Genowin Technologies\n”);
printf(“\nEnd of program\n”);
After writing a C program we need to compile it. Compilation is the process of converting human readable code into a form which the machine can understand. Command to compile
$ gcc test.c
If there is no error, the program will be successfully compiled and the compiler will create an executable file called a.out. Now to run our program, we have to execute a.out executable file.
You can specify an execuable file name while compiling program itself:
$ gcc -o test test.c
Now execute test (see output of test.c)
Happy To Help You ….
All Linux solution & Training.