2 votes 2 votes #include<stdio.h> int main() { int *ptr1,*ptr2; ptr1 = (int *)1000; ptr2 = (int *)2000; if(ptr2 > ptr1) printf("Ptr2 is far from ptr1"); return(0); } meaning of these below line and what if we dont include them ? ptr1 = (int *)1000; ptr2 = (int *)2000; sumit goyal 1 asked Jul 30, 2017 sumit goyal 1 389 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply saxena0612 commented Jul 30, 2017 reply Follow Share Pointer ptr1 and ptr2 are of type integers i.e ptr1 is pointing to an address that holds 4 bytes (assuming int is 4 bytes) Now when you are assigning an address to the pointer you need to typecast it with reference to the pointer type . Thus if ptr1 is pointing to 1000 then ptr+1 will point to 1004 and same for ptr 2 . 1 votes 1 votes sumit goyal 1 commented Jul 30, 2017 reply Follow Share thnks bhai 0 votes 0 votes joshi_nitish commented Jul 30, 2017 reply Follow Share ptr1 = (int *)1000; it means convert 1000 to an integer address that can be legally pointed by integer pointer.. now, no matter whether integer is present at an address '1000' or not, ptr1 will be pointing to address '1000' in memory, 1 votes 1 votes sumit goyal 1 commented Jul 30, 2017 reply Follow Share thanks in turbo c if i not type case it it is still working fine why 0 votes 0 votes Please log in or register to add a comment.
Best answer 0 votes 0 votes (int *)1000 ---> Here we typecast 1000 address to ineger to pointer. we can't directly assign the address to a pointer variable. for example in linked list when malloc function through address then we typecast it into ( struct node *) Optimus Prime answered Jul 30, 2017 • selected Jul 30, 2017 by sumit goyal 1 Optimus Prime comment Share Follow See all 0 reply Please log in or register to add a comment.