C course
The systems language: fast, close to the machine and the foundation of almost everything else.
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.
Basic C course
20 lessonsFrom scratch: everything you need to write your first programs.
- 1Hello, worldWrite your first C program: include stdio.h, create the main function and print text on the screen with printf, \n and \t.Lesson 1
- 2Variables and basic typesDeclare variables in C with the int, double and char types, change their values, use const and check with sizeof how many bytes each type takes.Lesson 2
- 3Arithmetic and castsDo maths in C: addition, subtraction, multiplication, integer division, the remainder with %, casts to double and int, and the += and ++ shortcuts.Lesson 3
- 4printf formatsMaster printf format specifiers in C: %d, %f, %c and %s, decimals with %.2f, column widths, %% and other formats for a shop receipt.Lesson 4
- 5Reading input with scanfAsk the user for data in C with scanf: words with %s, whole numbers with %d and decimals with %lf, and check how many values were read.Lesson 5
- 6Decisions with if and switchMake decisions in C with if, else if and else, and pick between several cases with switch, case, break and default: temperatures, scores and opening hours.Lesson 6
- 7Comparison and logicCompare values in C with ==, !=, < and >=, and combine conditions with &&, || and !. True is 1 and false is 0; plus the ?: ternary operator.Lesson 7
- 8while and do-while loopsRepeat code in C while a condition holds with while, and with do-while when the block must run at least once.Lesson 8
- 9for loopsUse C's for loop to count up and down, add things up, skip turns with continue, leave with break and nest one loop inside another.Lesson 9
- 10ArraysStore many values of the same type in a C array: a week of temperatures, their average and their maximum, with indexes that start at 0.Lesson 10
- 11Strings as char arraysWork with text in C as char arrays that end in '\0', using the string.h functions: strlen, strcpy, strcat and strcmp.Lesson 11
- 12FunctionsGroup code into C functions: void functions that return nothing, functions with a parameter and functions that give back a result with return.Lesson 12
- 13Parameters, returns and prototypesDeclare prototypes in C so functions can come after main, pass several parameters by value and use several return statements in one function.Lesson 13
- 14Scope and static variablesUnderstand where each variable lives in C: globals, locals, block variables and static ones, which keep their value between calls to a function.Lesson 14
- 15Pointers: address and valueLearn what a pointer is in C: a variable's address with &, its value with *, functions that change the caller's variables, and NULL.Lesson 15
- 16Pointers and arraysSee how pointers and arrays are related in C: the array name as an address, pointer arithmetic and arrays passed as function parameters.Lesson 16
- 17StructsGroup related data into a C struct: a shop's products with a name, price and stock, the dot, the arrow and pointers to structs.Lesson 17
- 18Enums and typedefName fixed values with enum in C and create short type names with typedef: a traffic light and the orders at a coffee shop.Lesson 18
- 19Writing and reading filesSave and read data in a text file in C with fopen, fprintf, fscanf and fclose, and add lines at the end with "a" mode.Lesson 19
- 20Project: a gradebookCombine everything from the C course in a gradebook: structs, arrays, an enum, functions, pointers and a report saved to a file.Lesson 20
Advanced C course
20 lessonsFor those who know the basics: the techniques used in real projects.
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 15The preprocessorUse the C preprocessor: constants and macros with parameters, # and ##, conditional compilation with #if, and include guards in headers.Lesson 15
- 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
- 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
- 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
- 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
- 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