🍚 C — Learn From Zero
Playground: Replit C | JDoodle — click, type, run.
What is C?
C is a low-level, fast systems language. It powers operating systems, embedded devices, and is the foundation of many modern languages.
- Operating systems (Linux, Windows kernels)
- Embedded & IoT
- Game engines & drivers
- Performance-critical code
Run Online — No Install
Use the playground links above.
🟢 Beginner — Core Basics
Your First Program
c
#include
int main() {
printf("Hello, world!\n");
return 0;
} Programs start in main().
Variables & Types
c
int age = 36;
float height = 1.78f;
double big = 3.14;
char c = 'A';Static types: int, float, char.
If / Else
c
int age = 18;
if (age >= 18) printf("Vote\n");
else printf("Too young\n");No bool keyword in C89; use 0/1.
Loops
c
for (int i = 0; i < 5; i++) printf("%d\n", i);
int n = 3;
while (n-- > 0) printf("%d\n", n);Classic C-style loops.
Functions
c
int add(int a, int b) {
return a + b;
}Declare before use or provide a prototype.
Pointers Intro
c
int x = 10;
int *p = &x;
printf("%d\n", *p);& gets address, * dereferences.
🟡 Intermediate — Building Real Programs
Arrays
c
int nums[5] = {1, 2, 3, 4, 5};
for (int i = 0; i < 5; i++) printf("%d\n", nums[i]);Arrays decay to pointers when passed.
Strings
c
char name[] = "Ada";
printf("%s\n", name);Strings are char arrays ending in \0.
Structs
c
struct Person { char name[20]; int age; };
struct Person p = {"Ada", 36};Group related data in structs.
Dynamic Memory
c
int *arr = malloc(5 * sizeof(int));
arr[0] = 1;
free(arr);Always free() what you malloc().
File I/O
c
FILE *f = fopen("a.txt", "w");
fprintf(f, "Hi");
fclose(f);Use fopen/fclose.
🔴 Advanced — Pro Concepts
Function Pointers
c
int (*op)(int,int) = add;
printf("%d\n", op(2,3));Pointers to functions enable callbacks.
Preprocessor
c
#define MAX 100
#ifdef DEBUG
printf("debug\n");
#endifMacros and conditional compilation.
Bitwise Ops
c
int flags = 1 | 4;
if (flags & 1) printf("bit0\n");Manipulate individual bits.
Unions
c
union Data { int i; float f; };
union Data d; d.i = 10;Share memory between members.
What's Next?
- Build a tiny project: Calculator, To-Do App, Weather Widget
- Read the official docs and a good book
- Solve Exercism exercises
- Join a community & share your code
Practice daily for 20 minutes. Consistency > intensity.