C-programming - Test c program on linux, How to test gcc is working

Test c program on linux

Install C / gcc compiler on LINUX
  # yum install gcc gcc-c++ autoconf automake 

Now lets start write our first C program
  # vi first.c

    #include <stdio.h>
    int main()
    {
      printf("Hello, World\n");
      return 0;
    }

Firstly compile the code using the following command
  # cc -c first.c

that would produce an object file you may need to add to the library.
# ls -l

-rw-rw-r--   1 info info   72 Jul 24 22:10 first.c
-rw-rw-r--   1 info info  856 Jul 24 22:11 first.o

then create an executable using the following command
  # cc -o first first.c

# ls -l
-rwxrwxr-x   1 info info 4643 Jul 24 22:12 first
-rw-rw-r--   1 info info   72 Jul 24 22:10 first.c
-rw-rw-r--   1 info info  856 Jul 24 22:11 first.o

Now run the executable as below
  # ./first
Now you would have created the executable file, run the the executable C program as shown above from the same directory.

Output:
  Hello, World
This will give the output of the first c program.

The topic on C-programming - Test c program on linux is posted by - Math

Hope you have enjoyed, C-programming - Test c program on linuxThanks for your time

Tech Bluff