How you can run a c program in Linux?

Posted on in Categories , , last updated October 16, 2007

Q. I’ve a c program and I’d like to run in Linux.

A. C program need to compile and run in Linux using cc or gcc command. When you invoke GCC (GNU C Compiler), it normally does preprocessing, compilation, assembly and linking for you. For example to compile hello.c program , type the following command:
cc -o hello hello.c
gcc -o hello hello.c

It will compile and produced an exectuable file called hello. To run program type:

11 comment

  1. Hello All,

    I need help. I have a ‘C’ program that was compiled on SCO OpenServer 5.05 and now want to compile on Linux Red Hut. This is failing to compile. Here is part of the program:
    #define MENU_WD 5
    #define MENU_HT 19
    #define MENU_HP 27
    #define MENU_VP 5


    struct s_menus{
    int ops;
    int y,x,w,o;
    int ptr;
    char title[20];
    char *options[10];
    typedef struct s_menus MENU;

    MENU m;
    int i;
    char a[20];

    menus_op(&m, “Student Records”);
    menus_op(&m, “Chameleon 2000”);
    menus_op(&m, “Change Password”);
    menus_op(&m, ” Exit”);


    How can I make this compile and run ?

    Thanking you in advance.

    Felix Mwango Mutale

  2. Try adding a header file to #include eg: #include

    main() has to be declared with a return value eg: void, int, char,

    put int main(){}

    compile now and see what happens.

  3. Dear Sir,

    I have been struggling to get bold letters in informix for CentoS 4.8 and how can I use PCL Command Sequences to solve this problem ?

    I have the following declarations and print command in my informix-4gl but things don’t seem to get right.

    BoldOn CHAR(6),
    BoldOff CHAR(6)

    —-LET BoldOn = ASCII 27, ASCII ‘&040’, ASCII ‘&115’, ASCII ‘&052’, ASCII ‘&066’
    —-LET BoldOff = ASCII 27, ASCII ‘&040’, ASCII ‘&115’, ASCII ‘&048’, ASCII ‘&066’

    LET BoldOn = ASCII 27,”(s4B”
    LET BoldOff = ASCII 27,”(s0B”

    COLUMN 54, BoldOn CLIPPED, ” “, “Ref: “, BoldOff CLIPPED, r_refno

    PRINT COLUMN 1, BoldOn CLIPPED, ” “, “This is to certify that: “, BoldOff, r_surname, ” “, r_firstname

    and this what I am getting:

    ^[(s4B TO WHOM IT MAY CONCERN^[(s0B ^[(s4B Ref: ^[(s0B 9844510
    ^[(s4B This is to certify that: ^[(s0B NAMONJE CAROL
    ^[(s4B is a registered student of the National Institute of Public Administration^[(s0B

    We have HP LaserJet P3005 and P3015 Printers.

    How can I avoid printing these charaters and instead print Bold letters ? Are there any settings I need to do in Environmental variables or CUPS settings ?

    Your help will highly be appreciated.

    Felix Mwango Mutale

  4. i have a compiled c file,i want to execute it and see its result on html page,like in gnome we type ./file name,then we can see the output but i dnt want to do this,i want to make it through html page,thats by click the ouptu should comew hw to do

Leave a Comment