







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








*a; a^
=^ malloc(n
sizeof(int));
^ Can we just say
a^
malloc(n*
Not a good idea After malloc, you have all the spaceneeded for the array allocated After that, you can use a[i] or *(a+i) toaccess the elements
*a; A^
=^ calloc(n,
sizeof(int));
^ Why do we use calloc? All elements areinitialized to 0 at the time of allocation
char quarterback[] = “Palmer”; 7 bytes are allocate for variable name. What if Mannings replaced Palmer as QB? char director[9]; Let’s say, a guy named Roethlisberger comes along. *char * quarterback;quarterback = (char ) malloc (15);
□ □ □ □
…□
”);^ □^ x 20
^ scanf(“%s”, temp_buffer); ^ title = (char *) malloc(strlen(temp_buffer)); ^ strcpy(title, temp_buffer);
p = null;
whenever
they free the memory p points to.