a.out? What's that?

Trip

Registered
I just recently compiled my FIRST ever C application! It's an extremely simple 'Hello World' application, but I'm proud! I've compiled the application using Terminal and typed it up using BBEdit.

Now the thing is: was it suppost to give me an window saying "Hello World"? Because it didn't! All I got was a file entitled 'a.out' in the same directory as the .c file that I compiled!

Can somebody explain to me what this a.out file is and what I'm suppost to do with it? Can somebody also explain why I didn't get a "Hello World" message?

Any help is appriciated! :D
 
When you compile, you simply generate the executable. If you run cc without the -o option, it'll put the executable into a.out. So to see your program run, simply run
Code:
./a.out
If you want a more meaningful executable name, run
Code:
cc -o myapplication myapplication.c
then the executable will be called myapplication.
 
Ok, the:


worked fine, it showed me the "Hello World" message in Terminal, but the:

cc -o testApplication THEFILE.c

Didn't work at all! All that did was put a file in the same directory entitled "testApplication". I know where the title came from, but it didn't do the "Hello World" thing like i was expecting...know what's wrong?!?!
 
Right, the compiler merely generates the application, so you still have to run it. So
Code:
./testApplication
is now how it would be run. The compiler doesn't actually run your code, it simply translates it into something the system can then run directly.

At this point, if you wanted to give anyone else your program, you'd give them testApplication which they could simply run. You could also go the open source route, and distribute the source, in which case anyone wanting to use it would first need to compile it as well.
 
But don't go distributing your programs just yet. The 'Hello World' program is a little on the small side... ;)

Yes, this post is meant to be funny!
 
Back
Top