C Programming for the Complete Newbie
Essay by review • August 29, 2010 • Study Guide • 1,917 Words (8 Pages) • 2,045 Views
C programming for the complete newbie
Hello there im Krisis you may have seen me on irc.hackersclub.com.
Well I thought it was about time to write an article like everyone else. But
unlike many others
mine wont be on Hacking, Cracking, or Phreaking it\'s on C programming, you
see I\'m not the best
hacker but I\'m an ok programmer. So here it goes. This is based for absolute
beginners so those
of you like my friend Chrak wouldn\'t be interested in it.
1st lets talk about some of C \'s history. C was invent by Dennis Ritchie
and Kenneth
Thompson. They modeled it after the language they were using called B. C
was a subset of B hence
the name. C was made because B was going out of style and they needed a new
language to write
UNIX in. Yes UNIX was made in C. C was made popular very quickly because
every UNIX sold had a C
compiler. A compiler is a program thats looks at your source code and
transfers it into object
code, after it is transferred
into object code it must be linked, once it\'s
linked it can be
executed.
/***************************************************************************
********************/
2nd Lets talk about variables they are your integers and characters and so
on. You have
many data types they are.
int integers
char characters
long int bigger integers
short int same as int
float decimal numbers
double even bigger decimal numbers
To define a variable 1st you must put something like int MyNum;
MyNum = 2;
or for a character value it would be like char name; name
= \'Jim\';
notice the \'\' you must have those around character values, they are not
needed for integers or
decimals.
/***************************************************************************
********************/
3rd I\'ll tell you about stuff like #include and #define. #include is used
to tell the
compiler that whatever is in the brackets just be included like its part of
your code.
#include <stdio.h>
#define is used to define something Like the color of a truck or car.
#define TRUCK \"red\"
#include and #define must come before any functions are even prototyped
(I\'ll talk about this
later).
/***************************************************************************
********************/
4th I\'ll talk about functions. Every program must have at least one
function. That
functions name must be main(). The () tells the compiler that it is a
function. All functions
must return a value in the main() function a 0 is usually returned. In your
functions you will
want to use comment\'s to explain your code a comment is begun by using /*
and ended by using */ .
I will now show you your 1st program.
#include <stdio.h> /* Used in most standard Input Output Programs */
main()
{ /* Beginning Brackets used to show the beginning
of
a block of code */
printf(\"Hello World\"); /* A function already written in Stdio.h */
return 0; /* Value returned from the program */
} /* Ending bracket used to show end of a block of code */
now compile your program in your compiler if your using UNIX do it like this
gcc hello.c -o Hello
and then run your program bye typing in ./Hello
/***************************************************************************
********************/
5th I\'ll talk about output which is essential
...
...