#Learn To Code C
Goals
- Understand the topics listed in the curriculum.
- Complete a personal project written in C.
- Contribute to an open source project that is written in C.
Prerequisites
- Familiarity with Command Line Interface (
pwd
,cd
,ls
,mkdir
,rmdir
,cp
,mv
,rm
) - The compiler setup
Week 1: Compilation
- Why Learn C?
- Compiling and Running C Programs
- gcc demo
- clang demo
- clang versus gcc from clang.llvm.org
- The "Main" Function
- Exercises:
- Hello World
- Formatted Printing from "Learn C The Hard Way" (Ignore the comments about using Make.)
- Fahrenheit to Celsius from "The C Programming Language" (Sections 1.2-1.4)
- Fizz Buzz
- Bonus: Euler Problem #1: Multiples of 3 and 5
- Bonus: Euler Problem #2: Even Fibonacci Numbers
- Bonus: Euler Problem #3: Largest Prime Factor
Week 2: Basics Part 1
- Variable Declaration
- Data Types
- Exercise: Types of Variables from "Learn C The Hard Way"
- Exercise: Finding the Size of Data Types
- Strings in C
- Exercise: Arrays and Strings from "Learn C The Hard Way" (Read the error output from the "break it" section here)
- Printing
- Conditionals
- Exercise: If, Else-If, Else from "Learn C The Hard Way" (Bonus: This exercise uses command line arguments.)
- Loops
- Exercise: Word Counter from "The C Programming Language" (Sections 1.5.1-1.5.2)
- Arithmetic Operations from "The C Programming Language" (Sections 2.5-2.6)
- Exercise: More Variables, Some Math from "Learn C The Hard Way"
- More Exercises:
- Bonus: Switch Statement from "Learn C The Hard Way"
- Bonus: Arrays of Strings, Looping from "Learn C The Hard Way"
- Bonus: While-Loop And Boolean Expressions from "Learn C The Hard Way"
Week 3: Basics Part 2
- Syntax Review
- Type Conversion from "The C Programming Language" (Section 2.7)
- Getting User Input
- Exercises:
- Sizes and Arrays from "Learn C The Hard Way"
- Writing and Using Functions from "Learn C The Hard Way"
- Project: Make a Game
- Bonus: Recursion Exercise from "The C Programming Language" (Section 4.10)
Week 4: C Specific Basics
- C Libraries
- Using multiple files in a project
- Advanced Compilation
- Exercise: Variations of Fizz Buzz
- External Variables
- Exercise: RPN Calculator from "The C Programming Language" (Sections 4.3-4.6)
make
and Makefiles- Exercise: Make some Makefiles
- reading and writing to files
- Exercise: Caesar Cipher
Week 5: Pointers and Standard Libraries
- Pointers:
- Pointers and Memory: Hands-on example of pointers and memory
- Chapter 5: Pointers and Arrays from "The C Programming Language" (Chapter 5)
- Pointers Dreaded Pointers from "Learn C The Hard Way"
- Pointers to Functions from "Learn C The Hard Way"
- Example: Caesar Cipher using Pointers
- Slides on Pointers and Memory from our lightning talk (Thanks @hazmatzo)
- Standard Libraries:
- C Standard libraries from Wikibooks "C Programming"
- Appendix B. Standard Library from "The C Programming Language" (Appendix B.)
Week 6: Memory Allocation
- Allocating Memory with
malloc
: summary of sections 5.4, 5.6, 6.5, and 7.8.5 from "The C Programming Language" - Freeing Memory: continued summary of memory management
- Reference Documentation for Malloc from Wikibooks "C Programming"
- Memory Allocation Intro Slides from U of Washington
- C Memory Management Examples from TutorialsPoint
- Exercises:
- Reimplementing
malloc
andfree
from "The C Programming Language" (Section 5.4) - Reversing User Input Tutorial Dynamic Array Example/Tutorial from CodeCall Forum
- Reimplementing
Week 7: Data Types
- Structs
- TypeDef from "The C Programming Language" section 6.7
- Unions
- Enums
- Slides on Data Structures
- Bonus Reading:
- More about Structs from "The C Programming Language" sections 6.1-6.2
- More about Unions from "The C Programming Language" section 6.8
- Exercises:
- Structs and Pointers To Them from "Learn C The Hard Way"
- Arrays of Structures from "The C Programming Language" section 6.3
- Bonus:
- Pirate Treasure Game Tutorial
- Heap and Stack Memory Allocation (uses Structs) from "Learn C The Hard Way"
- A Simple Object System (Uses Enum, Struct) from "Learn C The Hard Way"
- Input, Output, Files (Uses Enum, Struct) from "Learn C The Hard Way"
Week 8: Advanced Topic
- Binary Numbers:
- Intro to Binary and Hexadecimal Number Systems 🎥 from Khan Academy (for those who are not familiar with binary) or
- Binary Numbers Slides from Boston University CS101
- Bitwise Operators:
- Bitwise Operators in C from TutorialsPoint
- Bitwise Operators Section 2.9 from The C Programming Language
- Exercises:
- Two's Compliment:
- Two's Compliment
- More Exercises:
##Bonus Material:
###Small Tools
- Small Tools Intro
- Command Line Options & Arguments
- Exercise: Tip Calculator
- Exercise: D&D Character Generator
##Resources
Much of the material for this course was drawn from the following:
- "The C Programming Language" by Brian W. Kernighan and Dennis M. Ritchie
- "Learn C The Hard Way" by Zed Shaw
How to Host This Event
##License MIT License