PDA

View Full Version : newbie -- please help




sunil-delhi
Jul 9, 2006, 09:51 PM
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.



mduser63
Jul 9, 2006, 10:01 PM
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.

sunil-delhi
Jul 9, 2006, 10:52 PM
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.

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.

HiRez
Jul 10, 2006, 12:12 AM
3. gcc results in a.out containing gibberish.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

sunil-delhi
Jul 10, 2006, 10:40 AM
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



Thanx..

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

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

Great site..Great Group....