All in one forum  - Applications | Games | E-Books | Music, Movies & Videos | Mobile Stuff | Live Discussions | Webmaster Stuff | Many More | Community to Hang Out & Stick to
Search Today's Posts Mark Forums Read

Go Back   Home > Tutorial Section > Programming > C and C++
Reload this Page C Keywords
Forgot Password? Join Us!
C and C++ Post your C and C++ Related Tutorial Here

Notices
Free Image Hosting Solution for all Your link here @ 10$ 10 K Unique Visitors 1 Million Visitors Per Month Your link here @ 10$

Your Ad Here

Rate This Thread - C Keywords.

Post New Thread Reply
 
LinkBack Thread Tools Display Modes
  (#11 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:30 PM

KEYWORD if

If-else statements are the way to make the computer make decisions. Conditions are given to the computer in expressions that can be judged true or false. To a machine, zero is false, anything else if true. If, at the decision point, the expression is true, the computer takes one path otherwise it takes another. An if statement should follow the following form.
if( condition )
statement;
else
statement2;
There are several things to take note of here. First, there is no semicolon after ifs and else's. Only the associated statements have semicolons since they are technically part of the 'if' statement. Second, an if or else or(else-if), can have as many statements as you want, but if there are more than one, they must be enclosed in curly brackets. The statements can be anything, even more if statements. Finally, when I refer to a condition, I mean an expression that evaluates to either true or false. Here is a real example.
if( x >= 25 )
{
y++;
z++;
}
else
w++;
If x is greater than or equal to 25, y and z will be incremented, if x is less than 25, only w will be incremented.Sometimes you may not care about the else part. You might want some things to be done if a statement is true, but not do anything special if it is false. We then use what is called the null else. This simply means we forget about the else part. When the if is finished, there is no need to mention an else.
You can make longer if else structures by including else if statements. These are just like if statements, except they are only looked at if the first if, proves false. Here is what one might look like.

if( x == 3)
y++;
else if( x == 5 )
z++;
else
w++;
In this example, z is only incremented if x does not equal three and x equals five (the first if is false, and the else-if is true). W is only incremented if x does not equal three or five (the first and second ifs are false). And that should cover if else stuff in a nut shell.

TECHNICAL NOTES

*In a null else, we can type in the else and just put a semicolon after it like this else ;. Generally this would only be done to separate nested ifs when curly brackets are not used.
*When an if statement has more if statements in its statement section, those ifs are called nested ifs.
*Groups of statements enclosed by curly brackets are called compound statements. Essentially, the compiler sees these compound statements all as one.
*This is necessary because technically if statements can only have one statement associated with them.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
Click here to Donate to remove the Adverts.
Your Ad Here
  (#12 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:30 PM

KEYWORD int

Well, there just isn't much to it. The int keyword allocates the proper amount of memory for an integer value. An integer is a whole number, that means no decimals, or fractions. An integer can hold any value from -2,147,483,648 to 2,147,483,647 (on most operating systems). Use the int keyword to declare variables by first typing int, then the name the variable, then a semicolon, like this,
int x;
X is probably a common name for integers, but feel free to name it anything you want. However, it's good idea to avoid starting variable names with numbers or underscores (_). In fact, it's best not to start with any odd characters, letters are best. To assign a value to a integer, type its name then an equal sign, then the value, like this,
int x;
x = 56;
Also, you can declare and set a value for an integer, all in one line. start out the same, but before you put the semicolon, type an equal sign and then the number. Here is an example.
int x = 56;
NOTE: The spaces buffering the equal sign are optional.
TECHNICAL NOTES

*If you really want know why the value of integers must be between -2,147,483,648 and 2,147,483,647 it's because integers are given four bytes of space in memory. Each byte is made up of 8 bits, or binary digits. As you may know bits are the language of computers and are always either a one or a zero. So, and integer has 32 bits, that means there are 4,294,967,295 possible combinations of ones and zeros. Half of that is allotted for negative values (unless you declare it unsigned) which gives you a range of -2,147,483,648 to 2,147,483,647. You really don't need to know this stuff.
* Again, the figures above are typical for most operating systems, and processors, but it could be different.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
Click here to Donate to remove the Adverts.
Your Ad Here
  (#13 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:31 PM

KEYWORD new

The new keyword is used to dynamically allocate memory. The new keyword will look at what comes after it, and allocate a chunk of memory equal to that size. It then returns a pointer to that memory space. Here is the syntax:
object_pointer = new object;
In this example an object can be any kind of data storage. It can be a regular variable, a structure or an array. First a pointer to the desired type is needed. Type the pointers name, an equal sign followed by the new keyword, then the type of object. The result is that object_pointer now points to a new allocated chunk of memory. If there is no more memory to allocate, new will return null.
Since new is officially a C++ thing, older C compilers will not accept it. Instead you have to use a line like this: p = (object*) malloc( sizeof(object) );



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
  (#14 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:31 PM

KEYWORD sizeof

The sizeof keyword returns the size (in bytes) of variables (and other data objects). The format is simply this:
int_var = sizeof data;
Here, int_var is an integer variable. It must be assigned to the sizeof command. Data is any kind of data including variables, arrays, structures or just about anything. The sizeof keyword is frequently used for functions that require the exact size of an object as a parameter. No header files are needed to use sizeof because it is a C keyword, though people often mistake it for a function.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
Click here to Donate to remove the Adverts.
Your Ad Here
  (#15 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:31 PM

KEYWORD static

The static keyword is used to make static variables. Static variables are not destroyed when the function that created them is finished running. In other words they keep their data for the duration of the program. Here is the format:
static type varName;
First type the word static then the type of variable (it can be any type even arrays). Finally, put in the variable name. Static variables can be initialized like any other variable, but the initialization is only done once. The only time you should need a static variable is when you need a function to retain its data (or portions of it) every time it is called.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
  (#16 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:31 PM

KEYWORD struct

The struct keyword is used to define C structures. Structures are data objects that can hold groups of related variables even if they are of different types. Here is an example of a structure definition:
struct shape
{
int sides;
int color;
char name[20];
};
First use the struct keyword followed by its name (usually called its tag). Inside of curly brackets enter as many variable declarations as you need (these are called fields), this can even include previously defined structures. End with a semicolon. Note that this does not create any variables based on that structure. To actually make variables based on that structure you must declare them like this:
struct shape triangle, rectangle;
Again, start with the struct keyword, then use the structure's tag as the variable type, and then list your variable names as you normally would. You can use these variables just as you would an int, or any other variable type. They can even be passed to, and returned from functions. The only difference is that every place you use the variable type (the structure tag) you must put the struct keyword in front of it. Another way to declare variables based on a certain structure is to list the names after the closing curly bracket of the definition, but before the semicolon. Here is an example:
struct shape
{
int sides;
int color;
char name[20];
}triangle, rectangle;
To save yourself the hassle of typing struct all time, you can use the typedef keyword in you structure definition like this:
typedef struct
{
int sides;
int color;
char name[20];
}shape;
Notice the tag is now at the end of the definition. You can now do all same stuff as before, except without the struct keyword. To access the field of a structure, you must use the dot (.) operator. That is done by typing the variable name, a dot, then the filed name, like this:
triangle.sides = 3;
By using the dot operator to access fields you can use the fields just as you would an individual variable.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
Click here to Donate to remove the Adverts.
Your Ad Here
  (#17 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:32 PM

KEYWORDS switch case

Switch-case statements are used for something called multiway decision making. Essentially, a switch case structure is short hand for a long series of if, else if statements. It follows this general format:
switch( expression )
{
case value : statements;
case value2: statements;
.
.
.
default: statements;
}
Always start with the switch keyword followed be an expression to be tested. (Remember, expressions must evaluate to a single value). There is no semicolon at this point. Start the body of the switch with a open curly bracket ( { ). There must be one case statement for each value that should be compared to the expression. A case statement consists of the case keyword, and a value. These two things are collectively called the case-labeled statement or just the case label. The case label should be immediately followed by a colon (:) The value of the expression is compared to each case value until there is a match. When a match is found that becomes the entry point. All the statements associated with that case are executed. However, it doesn't stop there. ALL of the statements in the rest of the switch structure are executed regardless of their case label. Even the default is executed. This can be stopped by using the break keyword at the end of your case statements (more on that later).
The default is a special kind of label. If none of your case labels match the value of the switch expression then the default path will be taken. Note that the default is not required.
The statements following a case label may be almost anything. That includes things like loops, if else statements, and other switch case statements.
When you use the break keyword in a switch, you will interrupt the program flow. In other words, you will stop it from executed the code associated with the rest of the case statements instead of just the correct one. When you do this (use a break) the switch will act like a long if, else if sequence. If you include a default, that acts like an else statement. Here is the general form modified by the break statements.

switch( expression )
{
case value :
statements;
break;
case value2:
statements;
break;
.
.
.
default: statements;
}
NOTE: The last label, whether it is a case label or a default, does not need a break because the switch will be over at that point anyway. One last thing to mention is something called the mutivalued case statement. This is an instance when we want to use the program flow, instead of breaking it with a break keyword. The purpose is to allow two or more values to result in the same code being executed. To do this, we make a case label for each value, but do not associate any statements with them until we get to the last one. If any of these values are correct, the program flow will start there, and fall through until it hits the desired code. Here is a sample where this is used for an integer called n

switch( n )
{
case 1:
case 2:
case 3: printf("this will print when n = 1,2, or 3/n");
break;

case 4:
case 5:
case 6: printf("this will print when n = 4,5, or 6 /n);
}
Just like the printf statements say, if n is equal to 1, 2, or 3, the first printf will be executed. If n equals 4, 5, or 6 the second printf will be executed. If n does not equal any of those, nothing will happen.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
  (#18 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:32 PM

KEYWORD typedef

The typedef keyword is used to create your own variable types. This is usually done either as a short cut, or to improve the readability of code. For example if you are frequently defining strings of 100 characters, you might find it convenient to just make your own string type. Here is an example:
typedef char[100] string;
A new type is defined by using the typedef keyword followed by the full-length "normal" definition, then a name for the new type. Once this is done, you can use your new type just like any other. Example:
string description = "this is an example";
This is can also help prevent typos by shortening long definitions. Just imagine if you needed to declare several unsigned long integers. Compare having to type this several times:
unsigned long int x;
To just typing this:
//assume: 'typedef unsigned long int ULINT' has already been done
ULINT x;



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
Click here to Donate to remove the Adverts.
Your Ad Here
  (#19 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:33 PM

KEYWORD union

The union keyword is used to define C unions. A union is used to hold several types of variables in the same memory location. This means that only one of the variables can be used at a time. The size of a union will always be equal to the size of the largest data member. Unions are syntactically identical to structures. A union can be defined as follows:
. . .
union dataTypes
{
int x;
float y;
};

union dataTypes myData;
. . .
This, and any other valid structure definition method can be used. Data fields are accessed by using the dot operator(.) like this:
myData.x = 5;
A pointer to a union is accessed using the arrow (-> just like for structures (myDataPtr->x = 5). Note that when one data member is used, the other is destroyed. It is common in larger programs to used another variable to keep track of which field was last used. C unions do not have any intrinsic way of knowing which data member is the one currently in use.



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
  (#20 (permalink)) Old
 
KoOL's Avatar
 
User Info
Join Date: Oct 2007
Location: In You Mind
Age: 27
Achievements Posts: 10,860
Casino Cash: $1149880

Total Points: 238,247,191,105.98
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
01-04-2008, 05:34 PM

KEYWORD while

While loops are used to execute a set of instructions while a given condition is true. While loops are pre-test loops, which means that the condition is evaluated first, then, if it is true, the code in the body is executed. When the condition is false, the loop stops. In all pre-test loops it is possible to have zero iterations (the condition is false on the first try, so the body never gets executed). The format of a while loop is very simple, and looks like this.

while( condition)
{
statements;
}
There is no semicolon after the actual while line. With while loops we have the compound statement thing, just like for loops, and if else stuff. If you have more than one statement in the body, they must be enclosed in curly brackets. Other wise you can do this:
while( condition)
statement;
While loops will continue to execute the code in the body until the condition evaluates to zero. That's it!



For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
Reply With Quote
The Following User Says Thank You to KoOL For This Useful Post:
barnick (06-28-2008)
Click here to Donate to remove the Adverts.
Your Ad Here
Post New Thread Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is