calloc Allocation in C
Level 4142 keystrokes
Uses calloc to allocate zero-initialized memory for an array.
C code
// calloc(count, size) allocates and zeros memory1int *arr = (int *)calloc(5, sizeof(int));// Always check if allocation succeeded2if (arr != NULL) { // All elements are initialized to 03 for (int i = 0; i < 5; i++) { // Prints 0 0 0 0 0 without any explicit assignment4 printf("%d ", arr[i]);5 }6 printf("\n"); // Free allocated memory7 free(arr);8}Output
0 0 0 0 0
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
(× 8)× 8;× 6"× 4=× 3,× 2{× 2}× 2*× 2+× 2