| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | int main() |
| 4 | { |
| 5 | int A[5] = { 1,2,3,4,5 }; // this is allocated inside stack memory |
| 6 | int* p; // pointer of array |
| 7 | int i; |
| 8 | p = (int*)malloc(5 * sizeof(int)); // dynamically createing array inside heap |
| 9 | p[0] = 1; // initializing all the terms in array |
| 10 | p[1] = 2; |
| 11 | p[2] = 3; |
| 12 | p[3] = 4; |
| 13 | p[4] = 5; |
| 14 | |
| 15 | for (i = 0; i < 5; i++) // iteration for normal array |
| 16 | { |
| 17 | printf("%d ", A[i]); |
| 18 | } |
| 19 | printf("\n"); |
| 20 | for (i = 0; i < 5; i++) // iteration for the dynamic array |
| 21 | { |
| 22 | printf("%d ",p[i]); |
| 23 | } |
| 24 | return 0; |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected