HelloWorld in C... and on crack


Understanding how to use a command-line interface in order to compile and view/edit source, or an IDE that supports C may be used.
Linux/Unix typically comes with gcc, OSX users will need to download XCode (free with free registration) to install gcc, and Windows users (besides consistently being royally screwed in the butt) will need either Cygwin (for a Linux environment), MinGW (for gcc within cmd.exe), or Visual Studio C++ (Free express edition works fine, and make sure to use the Visual Studio command prompt instead of cmd.exe).
Previous programming experience helps, but is not assumed. Basic computer skills and ability to find easily available free-license software is assumed.

The tutorial itself is part of the source code. Inside the .zip file you'll find four sources: "helloworld.c", "helloworld_nocomments.c", "hello.c", and "hello.h". The main tutorial is "helloworld.c". You can open this in any text/source editor and follow along.

"helloworld_nocomments.c" is exactly the same as the tutorial file but without all the comments all over the place. This is so that you can have both open and easily scroll through the code without the comments; this way it's easier for you to see the program flow. The other two files are both part of the same program and are meant to be read after going through the initial tutorial. These two files have extremely minimal comments (just an intro for the files plus a short description of the C struct).

The tutorial goes through a basic Hello World example, plus additional functions, info on pointers, loops, and working with strings. I do not go into arithmetic since this isn't a math tutorial. I also don't talk much about conditionals. In fact, the only if-else statement is in the "hello.c" file, and the else{} clause is blank and only there to show syntax.

**Note on String Input: This program uses a buffer of size 1kB (1024 bytes) to take string input. Strings are terminated with a null character, so that leaves room for 1023 bytes of input. The "hello.c" program uses a function that cuts off at this limit, but the original tutorial does not! Therefore, be prepared for very strange things to happen should you run the original and feed input of 1kB or more. I will not be held responsible for you somehow causing a "format c:" to occur based on your stupidity (or really cleverness, cuz that'd be pretty sweet). If you really need more of an input buffer, you can change the size in the source.

This tutorial is not meant to be an all-inclusive how-to-program-in-C. It is meant to be a great jump-start into the language and a broad enough encompassing tutorial such that if/when you decide to use additional operations (arithmetic, trig from math.h, other truth conditions, etc) you will have a good idea what to look for and will easily understand how to use these new operations.

If you have any prior programming experience, this tutorial should be a piece of cake. If you have absolutely none and do not understand basic logic, then this could prove to be a challenge. Nevertheless, I'm confident that if you are eager to learn to program you should pick it up quickly by reading through the source. As this is the initial version, I expect there may be errors or various things I can change/update to make it better. Please feel free to comment and provide quality feedback.

As for compiling, these files have been tested and should compile with neither errors nor warnings on gcc and cl (Microsoft Visual Studio C++ Express Edition command-line compiler). Your commands are:
GCC: "gcc -o helloworld.exe helloworld.c"
CL: "cl helloworld.c"
and execute with "./helloworld.exe" on *nix or "helloworld" on Wind'oh's.

For the second part, replace "helloworld.c" with "hello.c".

Here is a sample run of the program (Note all versions produce the same run):

Hi, what's your name? Jerbo

Hello, Jerbo, how many friends are with you? 3

Name of friend #1: RaT

Name of friend #2: pirrup

Name of friend #3: EvX

Hello, RaT!
Hello, pirrup!
Hello, EvX!

Hello World!