Introduction: How to Program in C-simple Tutorial

Please Comment if you like this!

This Instructable will teach anyone to write a simple program in the C programming language.

What you will need:

a Macintosh Computer with the Developer tools installed,
and some brain power.

Step 1: Write Source Code

open the program Terminal in your Utilities folder, then type pico at the prompt.

Step 2: Type Source Code

Okay, now type this into the pico editor:

#include

int main()
{
printf("Hello!\n");
}

Step 3: Save Your Program

Now, save (Ctrl+o) the file as HELLO.C

Next, quit pico(Ctrl+x).

Step 4: Compile!

Type into the prompt:

gcc HELLO.C -o Hello

Step 5: Run Your Program!

In the prompt, type:

./Hello


This should run your program. Congratulations! You have just created your first C program!

Comments

author
tinkerC (author)2009-07-12

I am a C programmer. Although I wouldn't have ever learned much from this, it is nice to see something not Batch. P.S. Is it possible to tell an autorun.inf file to run a C program?

author
geeklord (author)2009-01-04

Can you make C files in Notepad++?

author
musicman432 (author)geeklord2009-01-05

Yes, but I believe that is only an editor. You would need to find a compiler too, such as the open source GCC compiler, try http://www.mingw.org/ or just google "gcc for windows".

author
geeklord (author)musicman4322009-01-06

thx

author
DeriemD (author)2008-07-02

that's not realy a c tutorial, it's more like how to write a c program

author
westfw (author)2007-12-28

I think that these days I'm inclined to recommend something like Processing to people who want to learn C. This is an "environment" with C underneath, but with major features implemented as a sort of "subset" so that you don't have to worry about quite as much. Also, it includes libraries of functions aimed at allowing relatively non-technical people to do fancy things (graphics...) (In the "microcontroller" space, Wiring and Arduino do the same thing (and in fact are based on the same core environment, I believe.))

author
GorillazMiko (author)2007-12-28

Let me tell you something -- I like it. Cool for a first instructable too. :-)

author
PocketSized (author)2007-12-28

It would have been nice if you had included some information explaining what each part of the code does. Such as '#include' being used to include an external header file. 'int main' is the body of the program etc I can't confess to knowing much C, which is why even the most basic of knowledge would be of use. Well done on your first Instructable through, nice to see something other than Batch :]

About This Instructable

6,567views

21favorites

More by musicman432:Mod the Mini ZT456 gun into airsoft pistolHow to program in C-simple tutorial
Add instructable to: