C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Explanation of program and figure

1. Code int *pc, p; creates a pointer pc and a variable c. Pointer pc points to some address and that address has garbage value.

Similarly, variable c also has garbage value at this point.

2. Code c=22; makes the value of c equal to 22, i.e.,22 is stored in the memory location of variable c.

3. Code pc=&c; makes pointer, point to address of c. Note that, &c is the address of variable c (because c is normal variable) and pc is the address of pc (because pc is the pointer variable). Since the address of pc and address of c is same, *pc (value of pointer pc) will be equal to the value of c.

4. Code c=11; makes the value of c, 11. Since, pointer pc is pointing to address of c. Value of *pc will also be 11.

5. Code *pc=2; change the contents of the memory location pointed by pointer pc to change to 2. Since address of pointer pc is same as address of c, value of c also changes to 2.

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business