C: Using realloc() To Resize An Array Of Ints.
https://github.com/pereiradaniel/c_programs/blob/master/dyn_mem/realloc/realloc.c // Dynamic Memory Allocation - realloc // ----------------------------------- // This program accepts user input to create a dynamic array of ints. // calloc zeroes the space first! #include <stdio.h> #include <stdlib.h> // calloc! int main(int argc, char* argv[]) { // Prompt user for number of ints for dynamic memory allocation: int num_ints = 0; printf("This program will dynamically allocate memory for an array of ints.\nHow many ints would you like? "); scanf(" %d", &num_ints); // Create a dynamically allocated array of integers using user input: int *a = calloc(num_ints, sizeof(int)); // Displays zeroed data first: printf("Using calloc zeroes all the data first:\n"); for (int i=0; i<num_ints; ++i) printf("a[%d] = %d\n", i, a[i]); printf("\n"); // new line! // Use for loop to a...