1 votes 1 votes #include<stdio.h> int main() { int arr[] = {10, 20, 30, 40, 50, 60}; int *ptr1 = arr; int *ptr2 = arr + 5; printf("Number of bytes between two pointers are: %d", (char*)ptr2 - (char*) ptr1); return 0; } Please explain the above code saipriyab asked Nov 21, 2017 saipriyab 3.0k views answer comment Share Follow See 1 comment See all 1 1 comment reply abhishek tiwary commented Nov 21, 2017 reply Follow Share 10 for 2B int 0 votes 0 votes Please log in or register to add a comment.
6 votes 6 votes Elements 10 20 30 40 50 60 Address 1000 1004 1008 1012 1016 1020 Assuming size of int = 4byte and size of char = 1byte ptr1 =1000 ptr2= 1000+5 {skipping 5 elements of size 4byte each} => ptr2 =1020 type casting is done here into char (char*)ptr2 - (char*) ptr1); 1020-1000=20/size of char o/p: 20 Akash Mittal answered Nov 21, 2017 Akash Mittal comment Share Follow See all 0 reply Please log in or register to add a comment.