DMarlon Studio

Advanced C course

For those who know the basics: the techniques used in real projects. In DMarlon Studio, C is written in the console target: the studio compiles and runs with one click and shows errors on the line where they are.

Start
  1. 1Pointers to pointers and arithmeticWalk C arrays with pointer arithmetic, subtract pointers, and use a pointer to a pointer so a function can change where another pointer points.Lesson 1
  2. 2Dynamic memory: malloc, calloc, freeAllocate memory at run time in C with malloc and calloc, check for NULL and release it with free: a class's marks and their histogram.Lesson 2
  3. 3realloc and a growing arrayBuild a dynamic array in C that grows with realloc, doubling its capacity, to store sensor readings without knowing how many will arrive.Lesson 3
  4. 4Strings in depthSplit lines with strtok, build text with snprintf without overflowing the buffer and copy safely with strncpy in C, plus strchr and strstr.Lesson 4
  5. 5const and pointersTell apart a pointer to const, a const pointer and both at once in C, and use const parameters to promise that a function only reads.Lesson 5
  6. 6Function pointers and callbacksStore functions in variables and arrays with C function pointers and pass them as callbacks: pricing rules applied step by step.Lesson 6
  7. 7qsort and bsearch with comparatorsSort an array of structs in C with qsort and a comparison function, then search it with bsearch: a shop's products by price and by code.Lesson 7
  8. 8Structs with pointers on the heapCreate an array of structs on the heap in C whose fields are dynamic memory too, and free all of it in the right order.Lesson 8
  9. 9A linked listProgram a linked list of tasks in C: nodes on the heap, adding at the end and at the front, removing by id and freeing the whole list.Lesson 9
  10. 10A stack and a queueUse a stack in C to check whether the brackets in an expression are balanced, and a circular queue for a printer's jobs.Lesson 10
  11. 11A binary search treeBuild a binary search tree in C that counts words: recursive insertion, lookup, in-order traversal and freeing the tree.Lesson 11
  12. 12A hash tableProgram a hash table with chaining in C: the djb2 function, buckets holding linked lists, collisions and looking up drink prices.Lesson 12
  13. 13Unions and bit fieldsStore values of different types in a tagged union and pack a date into bits with C bit fields, checking their size with sizeof.Lesson 13
  14. 14Bitwise operators and flagsStore several permissions in one integer with bit flags in C: set with |, clear with & and ~, toggle with ^ and test with &.Lesson 14
  15. 15The preprocessorUse the C preprocessor: constants and macros with parameters, # and ##, conditional compilation with #if, and include guards in headers.Lesson 15
  16. 16Variadic functionsWrite C functions that take a variable number of arguments with stdarg.h: an average of n values and a printf-style logger.Lesson 16
  17. 17Errors: return codes and errnoHandle errors in C with your own return codes, errno, strtol and strerror: validating order quantities and reporting a missing file.Lesson 17
  18. 18Binary files: fwrite and freadSave structs to a binary file with fwrite, read them with fread and jump to a record with fseek in C to change it without rewriting the file.Lesson 18
  19. 19Recursion and backtrackingSolve the N-queens problem in C with recursion and backtracking: try an option, carry on, and undo it when it leads nowhere.Lesson 19
  20. 20Project: inventory managerA small inventory manager in C that combines structs, dynamic memory, a linked list and files, and frees all its memory at the end.Lesson 20