C is for Cocoa
Subject:   Re: This made me install the dev tools
Date:   2003-07-23 21:04:40
From:   anonymous2
Response to: This made me install the dev tools

If you're anxious to get Mr. Roby's little sample to compile and run, let me give you a little nudge.

Getting a C program to run involves three steps:
1. Create your C source file. If you've never used vi or emacs then I would recommend pico. Save the source file as 'lesson1.c'.
2. Compile it into machine code:
gcc lesson1.c
3. Run your program and see your happy result:

I'm not going to go into how or why any of this works; I will let the excellent tutorial run its course. I will, however, say that despite what you've read, the line that begins with '#' (it's not a comment) must remain as an independent line.

Here is the entire program:

#include <stdio.h>
void main()
//Computes our favorite number
int favoriteNumber = (3 * 4) / 2; /*is anyone's favorite number not an int? */
favoriteNumber = favoriteNumber + 2;

/* now let's tell the world
what our favorite number is! */
printf("My favorite number is %d!", favoriteNumber);

1 to 2 of 2
1 to 2 of 2