389 views
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;

1 Answer

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 *)

selected by

Related questions

0 votes
0 votes
1 answer
1
anonymous asked Jun 26, 2016
678 views
0 votes
0 votes
1 answer
2
7 votes
7 votes
3 answers
3
Parshu gate asked Nov 20, 2017
780 views
What is the output of the following program?#include<stdio.h int main() { int array[]={10, 20, 30, 40}; printf(“%d”, -2[array]); return 0; }$-60$$-30$$60$Garbage valu...
3 votes
3 votes
1 answer
4
sumit goyal 1 asked Jul 30, 2017
360 views
explain this : how to identify whether a minus is unary minus and + is unary plus and what is difference between simple minus sign and unary minus sign and difference b...