Posted on 19th October 2009No Responses
Pointer Assignment- Definition and Example
Pointer Assignments
As with any variable, you may use a pointer on the right-hand side of an assignment statement to assign its value to another pointer. For example,
#include
int main(void)
{
int x;
int *p1, *p2;
p1 = &x;
p2 = p1;
printf(” %p”, p2); /* print the address of x, not x’s value! */
return 0;
}
Both p1 and p2 now point to x. The address of x is displayed by using the %p printf() format specifier, which causes printf() to display an address in the format used by the host computer.
Popularity: 1% [?]
Comments
Leave a Response