Essay Color Key

Free Essays
Unrated Essays
Better Essays
Stronger Essays
Powerful Essays
Term Papers
Research Papers

C Programming

Rate This Paper:

Length: 1423 words (4.1 double-spaced pages)
Rating: Red (FREE)      
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

C programming for the complete newbie

Hello there im Krisis you may have seen me on

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 transfered into object code it must be linked, once it's

linked it can be




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




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




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 */


{ /* Beginning Brackets used to show the beggining 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 to almost all programs.

I'll start you out with printf(); It is defined in Stdio.h so every time you

call printf(); you

must include Stdio.h .

printf(); 's syntax is quite easy you just used it like this

printf("What ever you want outputted");

to output variables you do it like this

char dog='scruffy';

printf("My dogs name is %c", dog); notice the %c it tells the compiler to

look for a character


Now for Integers and Decimals

int age=16;

printf("I am %d year's old", age); use %d to print out decimals and integers



6th Lets talk about multiple functions. When you have more than one function

you must prototype

it. Here is an example.

#include <stdio.h>

void hello(); /* This is a prototype notice the void. Void tells the

compiler that this function

does not return a value like return 0; */

main() /* Main doesnt ever need to be prototyped */



return 0;


void hello(); /* Your prototype must look exactly like your real function */


printf("Im in the function hello!");


Void is your return type. Other return types are int for returning integers

use float to return

decimals and so on.



7th I'll introduce you to input. Ill teach you how to use gets() and scanf()

and fgets() properly

gets() takes a variable and place data into as do scanf() and fgets() In the

next example I will

use all 3

#include <stdio.h>

#include <conio.h>



int x, y, z, ans;

printf("What is X 's value


printf("What is Y 's value

scanf("%d", &y); /* Scanf is odd I dont recommend using it try and use gets

and fgets more */

/* Whatever is used to print the variable type you are using is placed in

parantheses and & is

used in front of whatever variable you are using */

printf("What is Z 's value");

fgets(z, 25, stdin); /* fgets is kinda tricky at first glance */

/* first off you put what variable you want then how many integers or


long it can be and then stdin,stdin is a macro defined in stdio.h it is used

to represent

standard input */


printf("Ans equals %d", ans);



8th Lets talk about decision statements like if and else.

here is how if is used



printf("Your variable is 5");


else is used after if, it is used like this



printf("Your variable is 5");




printf("I dont know what your variable is");




9th Ill talk about While loops and do-while loops. Loops aren't as hard as

they may seem.

while loops are easy. Just watch and learn.

#include <stdio.h>



int x=1;




x++; /* adds 1 to x */


return 0;

} /* While loops dont have to happen only if the right sequence happens do

they execute */

Loops can be placed inside of IF and else statements if you want. That can

be very helpful if you

want a process to happen a bunch if something happens Like the user pressing

X instead of Y.

Do-While loops are just as easy. They automatically execute at least once.

#include <stdio.h>



int x=1;






return 0;


The do tells the program to do this at least once and it doesn't see the

while until it has

already do the do.



10th I'm going to tell you about another kind of loop the for loop. For

loops execute a given

number of times and then stop. For loops are executed like this.

for(x=1; x<100; x++)




That prints 1 through 100. Thats about it about for loops there not very

hard. They can be pretty

useful. But I dont use them alot I'm into While loops.



11th is all about Arrays. Arrays are consecutive places in memory. Arrays

can be integers and

characters. They can be just about any size. Here is an example.

#include <stdio.h>



int i[2]

int i[1] =2600

int i[2] =1982 /* Year I was born */

printf(" I[1] = %d ",i[1]);

printf(" I[2] = %d ",i[2]);

return 0;


See how easy that was Arrays aren't very hard at all.



12th I'll tell you about passing parameters to functions. Its nots to hard

but I've said that

about everything. First you must prototype it before main() I hope you

remember how to prototype.

Here is an example of passing parameters.

#include <stdio.h>

int next(int x);



int age;

printf("please enter you age ");

fgets(age, 3 ,stdin);

age(age); /* Age is passed on to the next function */

return 0;


next(int x);



printf("Next year you will be %d", x);

return 0;




13th I'll say a little sumthin about why C is good to Hacking. It's good

because it is so

portable C can be used on all processors and Operating Systems. So if your

exploit you just wrote works on

one UNIX like OS odds are it will work on another, therefore you dont have

to write a whole new

program just to get a root shell.



Last but not least a sample program.

#include <stdio.h>

int blah(int x,int y);



int a,b,r;

printf("Enter some numbers ");

scanf("%d", &a);

scanf("%d", &b);


printf("R = %d",r);

return 0;


int blah(int x, int y)

{ return x * y; }

What does blah do and how does it work? You tell me.



Thats it for my little tutorial on C. I hope it helped you some. But for

further info on C I

suggest reading

C programming in 12 easy lessons by Greg Perry from Sams Publishing.

It helped me a shitload on learning C. You also might want to get some books

on C++ a subset of C

You can mail me at

How to Cite this Page

MLA Citation:
"C Programming." 13 Oct 2015

Related Searches

Important Note: If you'd like to save a copy of the paper on your computer, you can COPY and PASTE it into your word processor. Please, follow these steps to do that in Windows:

1. Select the text of the paper with the mouse and press Ctrl+C.
2. Open your word processor and press Ctrl+V.

Company's Liability (the "Web Site") is produced by the "Company". The contents of this Web Site, such as text, graphics, images, audio, video and all other material ("Material"), are protected by copyright under both United States and foreign laws. The Company makes no representations about the accuracy, reliability, completeness, or timeliness of the Material or about the results to be obtained from using the Material. You expressly agree that any use of the Material is entirely at your own risk. Most of the Material on the Web Site is provided and maintained by third parties. This third party Material may not be screened by the Company prior to its inclusion on the Web Site. You expressly agree that the Company is not liable or responsible for any defamatory, offensive, or illegal conduct of other subscribers or third parties.

The Materials are provided on an as-is basis without warranty express or implied. The Company and its suppliers and affiliates disclaim all warranties, including the warranty of non-infringement of proprietary or third party rights, and the warranty of fitness for a particular purpose. The Company and its suppliers make no warranties as to the accuracy, reliability, completeness, or timeliness of the material, services, text, graphics and links.

For a complete statement of the Terms of Service, please see our website. By obtaining these materials you agree to abide by the terms herein, by our Terms of Service as posted on the website and any and all alterations, revisions and amendments thereto.

Return to

Copyright © 2000-2015 All rights reserved. Terms of Service