newbie -- please help

Discussion in 'Mac Programming' started by sunil-delhi, Jul 9, 2006.

  1. macrumors newbie

    Joined:
    Jul 9, 2006
    #1
    1. installed xcode on my ibook g4.
    2. wrote a small program using Vi editor.
    3. saved it with .c extension.
    3. gcc results in a.out containing gibberish.

    please help.
     
  2. macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #2
    We're going to need a lot more information that you just gave us. A listing of the code would be particularly helpful, as would the exact gcc command line you're using.
     
  3. thread starter macrumors newbie

    Joined:
    Jul 9, 2006
    #3
    frustration....

    The command line is "gcc sunil1.c". I precede it with rm a.out to ensure a fresh a.out each time.

    The program is a simple addition program in C.

    #include <stdio.h>
    int main()
    {
    int a,b;
    a=10;
    b=a+78;
    printf("%d",b);
    }



    gcc does not give any compilation errors.

    Quite frustrating why even this is not working.
     
  4. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #4
    a.out is compiled, executable machine code, it should appear as gibberish. To run it from the command line, navigate to the directory it's in and type

    ./a.out

    Or maybe I'm misunderstanding?

    EDIT: Forgot to mention, if you want it named something other than a.out, use the -o option:

    gcc sunil1.c -o myapp

    then run with

    ./myapp

    or to run it in a new Terminal window on OS X:

    open myapp
     
  5. thread starter macrumors newbie

    Joined:
    Jul 9, 2006
    #5
    thanx all..



    Thanx..

    twenty trial programs worked...all fine.....

    I will be trying the big ones over the next few weeks...

    Great site..Great Group....
     

Share This Page