5. Control structures
while (condition) statement_set;
do statement_set while (condition)
for (initial_cond, final_cond, change_action)
statement_set
if (condition) st_set else st_set2;
Master on Free Software
6. Data Types
● Simple types
– char, int, float, double
– signed/unsigned
● Complex types
– arrays, structures, unions
– strings (arrays of char ended in NULL)
● 'Special' types
– Pointers
– Void Master on Free Software
8. Data types
struct email {
int sent_date;
char *sender;
char *subject;
char *content;
};
struct email *myemail;
Master on Free Software
9. Arrays / pointers
● Array is actually a pointer to a chunk of
memory
● Uses of * and &
char *a;
char b;
*a?? &b?? (a = &b)?? (b = *a)??
● Pointer arithmetic: a[3] == *(a+3)
Master on Free Software
10. Operators
● Arithmetic (+, -, *, /, %)
● Logical (&&, ||, ==, !=, >=, <=)
● Increment / Decrement
● Size of a type
● Self assignment (+=, -=, ...)
Master on Free Software
11. Preprocessor
● Definitions
– #define, #undef
● Conditional compiling
– #if, #ifdef, #ifndef, #else, #endif
● Include other files
– #include
Master on Free Software