The C Reference provides a bird's-eye view of the most important syntax, data types, and library functions. Use this as a guide for quick lookup when writing or debugging code.
While sizes vary by architecture, these are the standard sizes for modern 64-bit systems:
| Type | Size | Format Specifier |
|---|---|---|
char |
1 Byte | %c |
int |
4 Bytes | %d |
float |
4 Bytes | %f |
double |
8 Bytes | %lf |
Standard structures for decision making and loops:
Pointers are variables that store memory addresses. They are the most powerful and dangerous part of C.
int *p; - Declaration of a pointer.p = &x; - Address-of operator (Assigns address of x to p).*p = 10; - Dereference operator (Accesses value at the address in p).NULL - A pointer that points to nothing (safe to check).Standard functions found in <stdio.h>, <stdlib.h>, and <string.h>:
| Function | Purpose |
|---|---|
printf() / scanf() |
Output to screen / Input from keyboard. |
malloc() / free() |
Allocate / Deallocate memory on the heap. |
strlen() |
Find the length of a string (excluding \0). |
fopen() / fclose() |
Open and close a file stream. |
Special characters used inside strings:
\n - Newline\t - Tab\\ - Backslash\" - Double Quote\0 - Null Terminator (End of string)The order in which operators are evaluated (Top = Highest):
(), [], ->++, --, !, *, &*, /, % then +, -<, >, ==, !=&& then ||=, +=, *= etc.