📚 PROGRAMMING GLOSSARY
Data Structures & Memory
array
Collection of elements of same type stored in contiguous memory
int numbers[5] = {1, 2, 3, 4, 5}; // array of 5 integers
struct
Custom data type that groups related variables together
struct student {
char name[50];
int age;
float gpa;
};
heap
Dynamic memory area where malloc/calloc allocate memory. You control when to free it
int *ptr = malloc(100 * sizeof(int)); // allocated on heap
stack
Automatic memory area where local variables live. Automatically cleaned up when function ends
void func() {
int x = 10; // x lives on the stack
}
Pointers & Memory Operations
pointer
Variable that stores the memory address of another variable
int x = 42;
int *ptr = &x; // ptr is a pointer, stores address of x
dereference pointer
Using * to access the value that a pointer points to
int value = *ptr; // dereference ptr to get the value
& operator
"Address of" operator, gets the memory address of a variable
int x = 10;
int *ptr = &x; // get address of x
-> operator
Shorthand for accessing struct members through a pointer
struct point *p = malloc(sizeof(struct point));
p->x = 10; // same as (*p).x = 10;
Data Types & Declarations
union
Like struct but all members share the same memory location
union data {
int i;
float f;
char c;
}; // only one member can hold a value at a time
enumeration (enum)
Defines a set of named integer constants
enum day {MONDAY, TUESDAY, WEDNESDAY}; // MONDAY=0, TUESDAY=1, etc.
unsigned
Data type modifier that only allows positive numbers (no negative)
unsigned int count = 42; // can't be negative, larger positive range
type alias (typedef)
Creates a new name for an existing data type
typedef struct point Point; // now can use Point instead of struct point
typedef int* IntPtr; // IntPtr is now alias for int*
Compilation & Preprocessing
compiler
Program that translates your C code into machine code that the CPU can execute
// gcc -o program program.c // gcc is the compiler
macro
Preprocessor directive that defines text replacement
#define SQUARE(x) ((x) * (x))
int result = SQUARE(5); // becomes ((5) * (5))
recursion
When a function calls itself to solve smaller versions of the same problem
int factorial(int n) {
if (n <= 1) return 1; // base case
return n * factorial(n - 1); // recursive case
}
Memory Issues & Debugging
memory leak
When you malloc memory but forget to free it
void bad_function() {
int *ptr = malloc(100 * sizeof(int));
// forgot free(ptr); - this is a memory leak
}
segmentation fault (segfault)
Trying to access memory you're not allowed to
int *ptr = NULL;
*ptr = 10; // segfault - dereferencing null pointer
buffer overflow
Writing past the end of an array
char buffer[5];
strcpy(buffer, "this string is too long"); // buffer overflow