#include #include #include int main(){ void *our_slab = malloc(1024*1024*1024); // We get a whole gigabyte! // This is called slab allocation int *ints = our_slab; for(int i = 0; i < 10; i++){ if(i == 0){ ints[i] = 1; continue; } int accumulator = 0; for(int j = 0; j < i; j++) accumulator += ints[j]; ints[i] = accumulator; } char *phrase = our_slab + 40; strcpy(phrase, "there are many squirrels in my neighborhood, but they fear my walnut tree. This is because I have crazy killer cats that patrol my yard. They EAT squirrels! The squirrels know this, and stay away."); puts(phrase); printf("["); for(int i = 0; i < 10; i++) printf("%d, ", ints[i]); printf("\b\b]\n"); free(our_slab); // This is not slab allocation double* pointer_to_the_number = (double*)malloc(sizeof(double)); *pointer_to_the_number = 4.321; printf("%lf\n", *pointer_to_the_number); free(pointer_to_the_number); return 0; }