malloc(…) is a function that allocates space ("allocation block") on the heap. - malloc(…) takes one parameter: the number of bytes to allocate. - malloc(…) returns the address of the first byte in the new allocation block. - malloc(…) returns type void* ("address of anything"). sizeof(…) is an operator that gives you the number of bytes needed to store an object. - sizeof(«VARIABLE») gives you the number of bytes needed to store an object of the same type as «VARIABLE». - int n = 5; sizeof(n) gives you 4 on our platform because n is of type int, and an int occupies 4 bytes on our platform. - Always use sizeof(«VARIABLE») (or sizeof(«EXPRESSION»)). - sizeof(«TYPE») gives you the number of bytes needed to store an object of type «TYPE». - sizeof(int) gives you 4 on our platform. - DO NOT USE sizeof(«TYPE»)!!!!!! free(…) is a function that deallocates (="frees") an allocation block. - free(…) takes one argument: the address of a block allocate by malloc. - You must call free(…) exactly once for every time you call malloc(…). TYPECASTS ARE EVIL ______ BAD: int* a_n = (int*) malloc(sizeof(*int)); // Typecasts are EVIL!!! ‾‾‾‾‾‾ GOOD: int* a_n = malloc(sizeof(*int)); // no typecast Example: char* s = "ABC"; int* a_n = s; // ERROR --- int* a_n = (int*) s; would silence the error but cause PAIN.