What's New!

Chat with
Hackers

How to Defend
Your Computer 

The Guides
to (mostly) 
Harmless Hacking

Happy Hacker 
Digests (old stuff) 

Hacker Links 

Hacker
Wargames 

Meet the 
Happy Hacksters 

Help for 
Beginners 

Hacker 
Bookstore 

Humor 

It Sucks 
to Be Me!

How to Commit
Computer Crime (not)! 

What Is a 
Hacker, Anyhow? 

Have a 
Great Life! 

News from the 
Hacker War Front

How to Program in C,continued...

"Hello, hackers!" Program Explained

So how did this program work? Let's look it over line by line. The first line is "#include<stdio.h>". This simply tells the computer how to accept input and make output ("stdio" is short for "standard input and output.") If you were to leave this line out, the computer wouldn't know how to output the message "Hello, hackers!."

The second line is "void main()". It tells the computer this is the main function under which all other C functions will run. "Main" might use many other functions (programs) while it is running, in this case the stdio program. The "void" tells the program that it doesn't have to pass a value to any other program when it is done running. You don't have to write "void" in front of "main()," but it's good programming practice.

The third line is just one character: "{". This tells your computer to expect the beginning of the main function.

The fourth line is "printf( "Hello, hackers!\n" );". The "printf" command tells the computer to use the stdio program to figure out how to print something to your monitor screen. "( "Hello, hackers!\n")" tells it what to print: the words "Hello, hackers!" followed by \n, which means "enter" (or "new line"). You have to have a new line command so your program will give a prompt back to you after it has run.

The ";" tells the C compiler that this is the end of this command, that whatever it sees next is the start of a new command.

The last character is "}" which simply means it is the end of the main function.

More on C --->>


Carolyn's most
popular book,
in 4th edition now!
For advanced
hacker studies,
read Carolyn's
Google Groups
Subscribe to Happy Hacker
Email:
Visit this group

 

Return to the index of Guides to (mostly) Harmless Hacking!

 © 2013 Happy Hacker All rights reserved.