C Reference Cheat Sheet Page 2

ADVERTISEMENT

C Reference Cheat Sheet
by
Ashlyn Black
via
Primitive Variable Types (cont)
Primitive Variable Types (cont)
-38
38
4
±1.2×10
to ±3.4×10
float
char x = 1, y = 2; float z = (float) x / y;
-308
308
8 /
±2.3×10
to ±1.7×10
OR alias to float
Some types (denoted with OR) are architecture dependant.
double
4
for AVR.
There is no primitive boolean type, only zero (false, 0) and non-zero
ARM: 8, AVR: 4, x86: 10, x64: 16
long double
(true, usually 1.)
Qualifiers
Flags variable as read-only (compiler can optimise.)
const type
Extended Variable Types
Flags variable as unpredictable (compiler cannot
volatile type
[class] [quali​ f ier] type name;
optimise.)
by ascending arithmetic conver ​ s ion
Storage Classes
From the stdint.h Library
Quick access required. May be stored in RAM OR a
register
Type
Bytes
Value Range
register. Maximum size is register size.
7
7
1
-2 to 2 -1
Retained when out of scope. static global variables
int8_t
static
are confined to the scope of the compiled object file
8
1
0 to 2 -1
uint8_t
they were declared in.
15
15
2
-2
to 2 -1
int16_t
Variable is declared by another file.
extern
16
2
0 to 2 -1
uint16_t
Typecasting
31
31
4
-2
to 2 -1
int32_t
Returns a as data type.
(type)a
32
4
0 to 2 -1
uint32_t
63
63
8
-2
to 2 -1
int64_t
64
8
0 to 2 -1
uint64_t
From the stdbo​ o l.h Library
Type
Bytes
Value Range
1
true / false or 0 / 1
bool
The stdint.h library was introduced in C99 to give integer types
archit​ e ct​ u re​ - in​ d ep​ e ndent lengths.
Structures
Defi​ n ing
A structure type strctName with two
struct strctName{
members, x and y. Note trailing semicolon
type x; type y; };
A structure with a recursive structure pointer
struct item{ struct
inside. Useful for linked lists.
item *next; };
Declaring
A variable varName as structure type
struct strctName
varName;
strctName.
By Ashlyn Black
Published 28th January, 2015.
Sponsored by
Last updated 20th April, 2015.
Measure your website readability!
Page 2 of 13.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education