Incrementing and Decrementing Pointers

main()
{
      int *a,*s,i;
      s=a=(int*)malloc(sizeof(int));
      for(i=0;i<4;i++)
             *(a+i)=i*10;
      printf("%d\n",(*++s)++); //Increments address by 4 and then value
      printf("%d\n",(*s)++); //Increments value only
      printf("%d\n",*++s); //Increments address only
      printf("%d\n", ++*s ); //Increments value only
      printf("%d\n",++s++); //Error

}

No comments:

Post a Comment