Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sunil-delhi

macrumors newbie
Original poster
Jul 9, 2006
5
0
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

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
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

macrumors newbie
Original poster
Jul 9, 2006
5
0
frustration....

mduser63 said:
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

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
sunil-delhi said:
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

macrumors newbie
Original poster
Jul 9, 2006
5
0
thanx all..

HiRez said:
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....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.