pointer subtraction

 #include <stdio.h>


int main(){
int a[]={3,5,6};
int * ptr1=&a[0];
int * ptr2=&a[1];

printf("The value of ptr1 is: %u\n",ptr1);

printf("The value of ptr2 is: %u\n",ptr2);
printf("The difference of ptr2 and ptr1 is %u\n", ptr2-ptr1);

 return 0;
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers