-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6b6f57
commit 5752e6a
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//pointer access - example | ||
|
||
#include<stdio.h> | ||
void main() | ||
{ | ||
int x, y; | ||
int *ptr; | ||
x = 10; | ||
ptr = &x; | ||
y = *ptr; | ||
printf("Value of x is %d\n\n",x); | ||
printf("x is stored at addr %u\n", &x); | ||
printf("y is stored at addr %u\n", &y); | ||
printf("value of y is: %d\n",y); | ||
printf("pointer variable ptr contains the addr %u\n", ptr); | ||
printf("pointer variable ptr itself is stored at addr %u\n", &ptr); | ||
*ptr = 25; | ||
printf("\nNow x has been assigned a new value through pointer which is= %d\n",x); | ||
} |