Dynamic Memory allocation concept Related to 1D array
#include<stdio.h> #include<stdlib.h> #include<string.h> main() { int a[4]={0},*p,i; p=malloc(4*sizeof(int)); for(i=0;i<4;i++) scanf("%d",&a[i]); for(i=0;i<4;i++) printf(" %d ",a[i]); }OutPut:
1 2 3 4 1 2 3 4