Pointers pre/post increment
Can anyone please explain the following code completely?

    
    #include<stdio.h>
    #include<stdlib.h>
    int main()

    {

    int *a,*s,i;

    a=s= (int *) malloc(4*sizeof(int));

    for(i=0;i<4;i++)

    {

    *(a+i)=i*10;

    printf(" %d ",*(a+i));

    }

    printf("\n");

    printf("%d\n",*s++);

    printf("%d\n",(*s)++);
    
    printf("%d\n",*s);

    printf("%d\n",*++s);

    printf("%d\n",++*s);

    printf("\n");

    printf("%d\n",*a++);

    printf("%d\n",(*a)++);
 
    printf("%d\n",*a);

    printf("%d\n",*++a);

    printf("%d\n",++*a);

    return 0;

    }

output:

 0 10 20 30

0

10

11

20

21



0 

11

12

21

22


   1) How pointer 's' is printing the values, where *(a+i) only been assigned
      the values in for loop?

   2) Where does the value go exactly and stored when *(a+i) is assigned?

   3) What's the difference between *s++, (*s)++, *++s, ++*s ?

   4) Why the values are incremented by 1 when i print the pointer a similar to s?


Thanks in Advance ! :)
Pointers pre/post increment
===

Can anyone please explain the following code completely?

    
    #include<stdio.h>
    #include<stdlib.h>
    int main()

    {

    int *a,*s,i;

    a=s= (int *) malloc(4*sizeof(int));

    for(i=0;i<4;i++)

    {

    *(a+i)=i*10;

    printf(" %d ",*(a+i));

    }

    printf("\n");

    printf("%d\n",*s++);

    printf("%d\n",(*s)++);
    
    printf("%d\n",*s);

    printf("%d\n",*++s);

    printf("%d\n",++*s);

    printf("\n");

    printf("%d\n",*a++);

    printf("%d\n",(*a)++);
 
    printf("%d\n",*a);

    printf("%d\n",*++a);

    printf("%d\n",++*a);

    return 0;

    }

output:

 0 10 20 30

0

10

11

20

21



0 

11

12

21

22


   1) How pointer 's' is printing the values, where *(a+i) only been assigned
      the values in for loop?

   2) Where does the value go exactly and stored when *(a+i) is assigned?

   3) What's the difference between *s++, (*s)++, *++s, ++*s ?

   4) Why the values are incremented by 1 when i print the pointer a similar to s?


Thanks in Advance ! :)