This is a draft cheat sheet. It is a work in progress and is not finished yet.
Declaring Variables
|
Signed integer. 1 bit to determine positive or negative and 31 bits for value. |
|
Unsigned integer. All 32-bits for values. |
|
Declare and asign a constant int. |
|
A single byte. |
Loop examples
for(int i = 0; i < 5; i++) {
printf("%i ", i);
} // Output 0 1 2 3 4
int j = 5;
while (j--) {
printf("%i ", j);
} // Output 4 3 2 1 0
|
|
|
Array Declaration
|
Char array with string literal. |
|
An array for 5 characters. |
char arr = {'A', 'B', '\0'};
|
With an array literal. |
|
Declaration of a pointer. |
Manipulating an Array
char s[] = "Hello";
// Read out one element
char FirstChar = s[0];
// Modify one element
s[1] = 'a';
// Read out each element
int len = strlen(s);
for(int i = 0; i < len; i++) {
printf("s[%i] = %c\n", i, s[i]);
}
|
|
|
|