Got stuck in the simplest problem.
int *p= (int *)malloc(m*sizeof(int));
p={0}; // this is not correct.
How to set the whole array to the value 0 other than using loops?
Got stuck in the simplest problem.
int *p= (int *)malloc(m*sizeof(int));
p={0}; // this is not correct.
How to set the whole array to the value 0 other than using loops?
 
    
    Either use calloc() rather than malloc() in the first instance to allocate the memory already zeroed, use  or memset() after the allocation:
 int * p = calloc(m, sizeof(int));
OR
int * p = malloc(m * sizeof(int));
memset(p, 0, m * sizeof(int));
Obviously, the former is preferable.
 
    
    use calloc:
 int * p = calloc(m, sizeof(int))
 
    
    