Showing posts with label memory. Show all posts
Showing posts with label memory. Show all posts

Sunday, August 21, 2016

Different way to access array elements

Do you know there are many ways to access the elements of array.
int Num[10];
for(int i=0;i<10;i++)
    printf("%d%d%d%d",Num[i],i[Num],*(Num+i),*(i+Num));
Here all the format will give the same result that is every element of Array.

Saturday, August 20, 2016

Malloc and Calloc

Difference between Malloc() and Calloc()
1. malloc() takes one argument while calloc() takes two argument
2. malloc() does not initialize the allocated memory while calloc allocated memory intialized with 0.
3. Both are used for dynamic memory allocation.
4. malloc is faster than calloc
5.Example: int *p=(int *)malloc(sizeof(int));
                   int *p=(int *)calloc(10,sizeof(int));