C Reference Cheat Sheet

ADVERTISEMENT

C Reference Cheat Sheet
by
Ashlyn Black
via
Number Literals
Primitive Variable Types
Integers
*applicable but not limited to most ARM, AVR, x86 & x64 installations
binary
binary
[class] [qualifier] [unsigned] type/void name;
0b11111111
0B11111111
by ascending arithmetic conversion
octal
decimal
0377
255
Inte​ g ers
hexadecimal
hexadecimal
0xff
0xFF
Type
Bytes
Value Range
Real Numbers
1
unsigned OR signed
char
88.0f / 88.1234567f
8
1
0 to 2 -1
unsigned char
single precision float ( f suffix )
7
7
1
-2 to 2 -1
signed char
88.0 / 88.123456789012345
2 / 4
unsigned OR signed
int
double precision float ( no f suffix )
16
31
2 / 4
0 to 2 -1 OR 2 -1
unsigned int
Signage
15
15
31
32
2 / 4
-2
to 2 -1 OR -2
to 2 -1
signed int
42 / +42
positive
negative
-42
2
unsigned OR signed
short
Binary notation 0b... / 0B... is available on GCC and most but not all C
16
2
0 to 2 -1
compilers.
unsigned short
15
15
2
-2
to 2 -1
signed short
Variables
4 / 8
unsigned OR signed
long
Decl​ a ring
32
64
4 / 8
0 to 2 -1 OR 2 -1
unsigned long
A variable.
int x;
31
31
63
63
4 / 8
-2
to 2 -1 OR -2
to 2 -1
signed long
A variable & initialising it.
char x = 'C';
8
unsigned OR signed
long long
Multiple variables of the same type.
float x, y, z;
64
8
0 to 2 -1
unsigned long long
A constant variable: can't assign to after
const int x = 88;
63
63
8
-2
to 2 -1
signed long long
declar​ a tion (compiler enforced.)
Floats
Naming
Type
Bytes
Value Range (Norma ​ l ized)
Alphanumeric, not a keyword, begins with a
johnny5IsAlive; 
letter.
Doesn't begin with a letter.
2001ASpaceOddysey; 
Reserved keyword.
while; 
Non-alphanumeric.
how exciting!; 
iamaverylongvariablenameohmygoshyesiam; 
Longer than 31 characters (C89 & C90 only)
Constants are CAPITALISED. Function names usually take the form of a
verb eg. plotRobotUprising().
By Ashlyn Black
Published 28th January, 2015.
Sponsored by
Last updated 20th April, 2015.
Measure your website readability!
Page 1 of 13.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education