This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

C Reference (For Liunx) By Qazjap11

0.00 (0 votes)
Document Description
C Reference (For Liunx) By Qazjap11
File Details
Submitter
  • Name: Qazjap11
Embed Code:

Add New Comment




Related Documents

C standart library reference by Qazjap11

by: Qazjap11, 30 pages

C standart library reference by Qazjap11

Buying a Home for Sale by Owner

by: foreclosuredatabank, 3 pages

ForeclosureDataBank.com provides hot tips on avoiding the pitfalls that may accompany a home for sale by owner deal.

C Reference Card (ANSI)

by: desantis, 2 pages

C Reference Card (ANSI) C Reference Card (ANSI) C Reference Card (ANSI) C Reference Card (ANSI) C Reference Card (ANSI)

1000 Questions For Couples By Michael Webb

by: ryan, 1 pages

1000 Questions For Couples By Michael Webb

Popular Class C Motorhomes | Best Class C Motorhomes for Family Travel

by: rv-motorhomes, 1 pages

Popular Class C Motorhomes | Best New 2013 Class C Motorhomes for Family Travel

THE ARMY LEADERS' DESK REFERENCE FOR SOLDIER/FAMILY READINESS

by: alina, 38 pages

Purpose This desk reference provides commanders and leaders at all levels with a concise guidebook for preparing soldiers, their families, and volunteers for training missions and real-world ...

C++ projects for class 12

by: daisi, 2 pages

C++ Projects for Class 12 www.cppforschool.com TOPIC STOCK MANAGEMENT SYSTEM BANK TRANSCATION SYSTEM LIBRARY MANGAMENT SYSTEM ...

Trying to Avoid Paying Listing Commision With For Sale By Owner

by: realestatetnnash, 3 pages

Are you thinking about trying to sell your home, but you’d like to do it yourself to try and save a little money? Industry expert Monte Mohr has prepared some advice on how to go at it alone in ...

Java Property, VM Option, and Info.plist Key Reference for Mac OS X

by: manualzon, 14 pages

Java ebook Java Property, VM Option, and Info.plist Key Reference for Mac OS X.pdf, Java Property ebook, java properties, java system property ebook, java able ebook free as well as other tutorials

camcorder battery suitable for DMT BY-B99 DMT BY-C101 DMT BY-C102

by: junealice, 3 pages

http://www.charger-battery.ca/battery_DMU_FIT_30678.htmcheap DMT BY-B99 DMT BY-C101 DMT BY-C102 camcorder battery,high quality rechargeable DMT BY-B99 DMT BY-C101 DMT BY-C102 camcorder ...

Content Preview
C standard
library
reference
(for Linux)
by Qazjap11

Published with CC-BY-SA 3.0 License

C functions and statements for Linux
Written by Qazjap11
Operators
Arithmetic operators:
var = something - put something into var
example: var = 5; // 5
+ add
example: var = 5 + 5; // 10
- substact
example: var = 5 - 5; // 0
* multiply
example: var = 5 * 5; // 25
/ divide
example: var = 5 / 5; // 1
% reminder of division
example: var = 5 / 3; // 2
Bitwise operators:
x >> n - shift bits in x n times right
example: var = var >> 1; // 5=00000101 => 2=00000010
x << n - shift bits in x n times left
example: var = var << 1; // 5=00000101 => 10=00001010
& AND operation
example: var = 3 & 5;//00000011 & 00000101 = 00000001
| OR inclusive operation
example: var = 3 | 5;//00000011 | 00000101 = 00000111
^ OR exclusive operation
example: var = 3 ^ 5;//00000011 ^ 00000101 = 00000110
~ reverse bits
example: var = ~var; // 5=00000101 => 250=11111010

Compound assignment operators:
+= add to itself
example: var += 3; // 8
-= subtract from itself
example: var -= 3; // 2
*= multiply itself by
example: var *= 3; // 15
/= divide itself by
example: var /= 5; // 1
%= set as reminder of devision itself by
example: var %= 3; // 2
a++ add one after making operation
example: printf("%d",var++); // prints 5 => 6
a-- subtract one after making operation
example: printf("%d",var--); // prints 5 => 4
++a add one before making operation
example: printf("%d",++var); // prints 6 => 6
--a subtract one before making operation
example: printf("%d",--var); // prints 4 => 4
Compound assignment bitwise operators:
x =>> n - shift bits in x n times right & assign to x
example: var =>> 1; // 5=00000101 => 2=00000010
x =<< n - shift bits in x n times left & assign to x
example: var =<< 1; // 5=00000101 => 10=00001010
&= AND operation to itself
example: var &= 3; //00000011 & 00000101 = 00000001
|= OR inclusive operation to itself
example: var |= 3; //00000011 | 00000101 = 00000111
^= OR exclusive operation to itself
example: var ^= 3; //00000011 ^ 00000101 = 00000110

Logical & Comparative operators:
== if equals to
example: 5 == 5 // true
!= if not equals to
example: 5 != 4 // true
> if bigger than
example: 5 > 3 // true
< if smaller than
example: 5 < 6 // true
>= if bigger or equals to
example: 5 >= 2 // true
<= if smaller or equals to
example: 5 <= 5 // true
= if can associate (not if equals!)
example: var = 5 // true
&& and
example: 5 == 5 && 5 < 6 // true
|| or
example: 5 == 4 || 5 < 6 // true
! not
example: !(5 == 4) // true

C statements & flow control
Statements:
In c almost all statements end with ';':
statement1; statement2;
Compound statements don't.
There is no importance to new lines, spaces or tabs.
Conditions:
if(condition is true)
{
something;
}else if(other condition is true){
something else;
}else{
other thing;
}
example:
if(var == 5)
{
printf("Var is 5\n");
}else if(var > 5){
printf("Var is bigger than 5\n");
}else{
printf("Var is smaller than 5\n");
}
While loop:
while(condition)
{
something;
}
example:
while(i<4)
{
printf("%d\n",i);
}

Do-While loop:
do{
something;
}while(condition);
runs at least one time.
example:
do{ printf("%d\n",i);
}while(i<4);
For loop:
for(initialize statement; condition; post loop
statement)
{
do something;
}
example:
for(i=0; i<5; i++)
{
printf("%d\n",i);
}
All above are optional, but ';' is required. For
example: for(;;) is an endless loop (without stop
condition).

Switch:
switch (var)
{
case something:
{
....
break;
}
case something else:
{
...
break;
}
default:
{
... break;
}
}
The {} after each case are not obligated, but they
form the code. Notice that the variables in the {}
are local to the block!
example:
switch(x)
{
case 1:
{
printf("X is 1\n");
break;
}
case 2:
{
printf("X is 2\n");
break;
}
default:
{
printf("X is neither 1 nor 2\n");
break

}
}
Structs
struct name {
int var1;
char var2;
...
}; // without instances
struct name xxx; // declare instance
struct name {
int var1;
char var2;
...
} first, second; // without initialization
struct name {
int var1;
char var2;
...
} first = {13,'c',...}; // with initialization
first.var1 = 44; // access struct members
printf("%c\n",first.var2); // access struct members
first = second; // assign first struct's members to
second
struct parent {
int var;
};
struct child {
struct parent p;
} c;
c.p.var = 4; // complex structs
struct dot {
int x;
int y;
} dots[3] = {1,2,2,3,3,4};

dots[0].x = 5; // struct arrays
struct name {
int var;
} x;
struct name *ptr = &x; // pointer
(*ptr).var = 4; // first access method
ptr->var = 4; // second access method
x.var = 4; // third access method
struct dot {
int x;
int y;
} dots[3] = {1,2,2,3,3,4};
struct dot *ptr = dots; // dots is pointer to dots[0]
ptr++; // go to dots[1], increase by dot struct size
typedef struct {
int x;
int y;
} dot; // define dot struct as dot variable
dot bottom,top; // using it
Unions:
Unions hold one value over various variables:
union name {
int i;
double z;
char c;
} instance;
instance.c = 1; // 1 is in all types
printf("%d\n",instance.i); // 1
printf("%lf\n",instance.z); // 1
Size of a union is the size of it's biggest member

Variables
Variable
Size X86
Size X64
int*
4 bytes
4 bytes
long
4 bytes
8 bytes
short
2 bytes
2 bytes
float
4 bytes
4 bytes
double
8 bytes
8 bytes
char
1 byte
1 byte
unsigned
4 bytes
4 bytes
unsigned long
4 bytes
8 bytes
* int's size is different in different compilers, tested in gcc
Printf/Scanf
Flags:
- align to left (if there isn't, to right)
+ always show number's sign
0 fill empty spaces in field width with zeros
Field width:
%2d - 2 numbers
%.2f - 2 fractional numbers
%2.2f - 2 numbers and 2 fractional numbers
%*d - width specified in variable
Formated vars:
%d,%i - decimal integers
%o - octal integers
%u - decimal unsigned
%x,%X - small and BIG hexadecimal values
%f - float
%lf - double
%Lf - long double
%c - char
%s - string
%% - % sign
%[set] - scan if these chars
%[^set] - scan till these chars
%n - scan number of chars entered

Download
C Reference (For Liunx) By Qazjap11

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share C Reference (For Liunx) By Qazjap11 to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share C Reference (For Liunx) By Qazjap11 as:

From:

To:

Share C Reference (For Liunx) By Qazjap11.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share C Reference (For Liunx) By Qazjap11 as:

Copy html code above and paste to your web page.

loading