Quick Introduction to C

C Preprocessor

C preprocessor code will be executed before compiling the actual c code.
Preprocessor lines start with # and do not end with a semicolon (in contrast to usual code instructions).

1
2
#define MAX_SIZE = 1
#undef MAX_SIZE

The first instruction replaces instances of MAX_SIZE with 1. The second instruction undefines the previous made call.

1
2
#include <stdio.h>
#include "myheader.h"

Tells the cpp to include stdio.h from the system libraries, where else the next line includes the header file myheader.h from the local directory.

1
2
3
4
5
6
7
#ifndef MAX_SIZE
...
#endif

#ifdef DEBUG
...
#endif

Pointers

A pointer points to a variable address/stores a variable address.

1
2
3
4
char val = 'c';
char val2;
char *pointer = &amp;val;
val2 = *pointer;