Program 102 #P102 -C Program Example How Pointer Works #C228
Explanation of the program
int* pc, c;
A pointer variable and a normal variable is created.
Here, a pointer pc and a normal variable c, both of type int, is created.
Since pc and c are not initialized at first, pointer pc points to either no address or a random address. And, variable c has an address but contains a random garbage value.
c = 22;
22 is assigned to variable c.
This assigns 22 to the variable c, i.e., 22 is stored in the memory location of variable c.
Note that, when printing &c (address of c), we use %u rather than %d since address is usually expressed as an unsigned integer (always positive).
pc = &c;
Address of variable c is assigned to pointer pc.
This assigns the address of variable c to the pointer pc.
You see the value of pc is same as the address of c and the content of pc is 22 as well.
c = 11;
11 is assigned to variable c.
This assigns 11 to variable c.
Since, pointer pc points to the same address as c, value pointed by pointer pc is 11 as well.
*pc = 2;
5 is assigned to pointer variable's address.
This change the value at the memory location pointed by pointer pc to 2.
Since the address of the pointer pc is same as the address of c, value of c is also changed to 2.
|| Like-Comment-Subscribe-Share ||
||Support and Subscribe ||
#rubalsolutions #coding #developer #programming #programmer #technology #clanguage #computerscience #c #informaticpractices #sub #subscribe #youtube #newyoutuber #youtubechannel
To Install Turbo C++ 4.5 Click on Below Link and Download rar file and extract and then install..
address updated by app.box.com on 8 april
https://app.box.com/s/soz2137zo0rv0sb08pf4upzgj01umfjr
Do Like,Comment,Share and Subscribe if u are learning little bit.
Please give me suggestions in form of comment box .
Link To My Blog - https://www.blogger.com/blogger.g?blo...
Like me on Facebook @ https://www.facebook.com/rubalsolutions/
Follow me on Twitter @ https://twitter.com/ruby0071
Follow me on Instagram @https://www.instagram.com/er.rubal/
Email me at :- ruby0071@gmail.com
Recording Microphone Mic & Tripod Stand for Laptop
https://amzn.to/2WCV5a8
Mini Professional Handheld Microphone Compatible with Xiaomi, Lenovo, Apple, Samsung, Sony, Oppo, Gionee, Vivo Smartphones (One Year Warranty)
https://amzn.to/2HRp1fj