Search the Web
Welcome to the nifty world of C programming. Well I'm starting the whole thing over my friends and it will be better this time. Not only will these tutorials be a little more indepth then the previous, but it will also feature eye popping special effects, thx sound, and a special guest appearance by Jennifer Love Hewitt.

History of C

"Hey Dennis, why don't you make a programming language for unix."
"Okay Brian, but you have to help me write the book for it."
"No problem man!"
"Pass the twinkies my brutha."
"Dude I think we're out of twinkies."
"WHAT!!!! You mean to tell me that here in Bell Labs, where we created the transistor, Unix, and the 10 cent a minute long distance dialing plan we can't keep a steady supply of twinkies!"

C was brought to us by those fine people at Bell Labs. You know those at&t people? They had themseves this Operating System called Unix, that needed a programming language. They made it, and since the previous version was called B, they decided to call it C for obvious reasons. No, there was never an A programming language. I say that so you won't embarass your self on an IRC, dang those guys can be brutal. It was written by this guy named Dennis Ritchie. The B in B stood for Bell by the way. So if your ever on jeapordy, now you know.

The workings of C

C is a compiled language. In your cooky compiler it takes the C "code" that you write and breaks it down into these itsy, bitsy, teenie, weenie, 1's and 0's. This is what the computer understands. 1's and 0's. This is called machine language. I still find it amazing that for all the power that a computer has it's just working off a base 2 number system. Wouldn't it be different if humans used base 2? In the lottery you'd only have 0 and 1 too choose from. Roulette would be like, "C'MON 1...C'MON 1....OHHHHHHHH!!!!!" After you compile your source code a thing called an object file is created. Afterwards, if it is brave and it's heart remains pure it is ran through the linker which turns it into an excecutable file. Let's write a simple C program shall we? Don't worry if you don't understand everything I'm about to say. Just copy the source code, I'll break down all lines of code. Do not use capital letters!!!!!! !! Do not copy and paste this code!!!! The < stdio.h > is confusing to your browser, since it looks, smells, and tastes like an html tag. I had to use some spaces. So if you cut and paste it will not work!!! SO there!!!!

#include < stdio.h >
main ( )
printf ("Goodbye Cruel World!!!!");
return (0);

Compile and run. You should get something like Goodbye Cruel World!!!! on your screen.

1st line
This stdio.h stands for standard input output header. Basically the code is "telling" your computer to use a certain command that is found in the stdio.h "file". There are a lot of "#include" files and they all have these wild commands in them, that you can access using the #include thingee.

2nd line
main ( )

This is the main function. There are many functions and all will have to do battle to be worthy of the title main. Okay all joking aside, in C you can have a lot of different functions. These can be titled; main ( ), function1 ( ), function2 ( ), and so on. What you have typed has but one function in it that will do your bidding. It's really not important that you know all of this in your infant stage, but I mention it anyways.

3rd line
This is the all important curly bracket. It is used to seperate "blocks of code" from each other and keep them from fighting each other. Just Kidding.

4th line
printf ("Goodbye Cruel World!!!!");
This is the printf command. It "hides" in the stdio.h file and waits to be called. And now in this line we use it. The printf commands stands for "print format." It is not print function as some believe. It bascially takes the text within the quotation marks and displays it on the screen. "Hey Digital you used capitals." Arrrgghh caught red handed. It won't affect C's case sensitive nature if you use it in this case. "Why does it display on the monitor digital?" Well son, way back in the day before monitors they used teletype (ancient printer) machines to display stuff from the computer. No games back then, too much paper. All printf does is take the stuff you want written and puts it on the screen. YOU MUST ENCLOSE WHAT YOU WANT WRITTEN ON THE SCREEN IN QUOTATION MARKS AND PARENTHESIS! YOU MUST ALSO END THE LINE WIT A SEMI COLON! DO NOT QUESTION IT, JUST DO IT!

5th line
return (0)
This is way too ahead of you at this critical jucture of your C writing career. It returns a value of 0 back to your....see! I can tell your snoozing off already. Just kidding. I'll explain it all later!

6th line
You are enclosing your block of code so it won't get into a fight. Just kidding. Here is where you end this block of code.

So now you've written your first C program. Compile it and run it. Bask in the glory of your accomplishment. Savor this moment young jedi for things get a whole lot more complicated in the future.

"Say digital what if I have more to say?" Good question. 1 line sentences just aren't sexy in our complicated world. Let's add a second line of text by using the newline escape character.

#include < stdio.h >
main ( )
printf ("I fart in your general direction!!!!!!\n");
printf ("Your father was a hamster and \n");
printf ("your mother smelled of elkenberries!!!!!");
return (0);

So here you go. Compile this bad boy and run it. You should get a similar output, but with 3 lines of text. Whenever you use a front slash the compiler says, "Oh my gosh and escape sequence!!!" The printf ignores the n, cuz it has been identified in such a manner.
Ahhhh, the assertation of knowledge. Weeeeeeell, that's all for now folks! I'll see you wacky internet people later - Digitalscribe

Back to Tutorials page