Monday, July 27, 2009

Wat is the output of the following C program? Can pointers be compared?

main()


{


int a=5,b=-5;


int *p1,*p2;


if(p1 == p2)


{ printf("the values are equal');


}


else


{printf("they r not equal");


}


}

Wat is the output of the following C program? Can pointers be compared?
hey dude!!!!


p1 and p2 in this prog contains junk values.....if in this prog if the address of a is assigned to p1 and addr of b is assigned to p2 then the o/p will be


they r not equal.





see...the pointers store the address of another variable...its an integer(hexa decimal to be precise)so it can be compared!!!!


No comments:

Post a Comment