comparing pointers

 #include <stdio.h>


int main(){
int arr[10];
int * ptr= &arr[0];
ptr=ptr+2;
if(ptr==&arr[2])
{
    printf("These point to the same memory location\n%u %u",ptr,&arr[2]);
}
    else
    {
        printf("These do not point to the same memory location\n");
    }

 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