Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
int main() { // Allocate memory for a number of items int numItems = 15; int *myArray = calloc(numItems, sizeof(int)); // Write into the memory for(int i = 0; i < numItems; i++) { myArray[i] = i + 1; } // Display the contents of the memory for(int i = 0; i < numItems; i++) { printf("%d ", myArray[i]); } // Free the memory free(myArray); myArray = NULL; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15