CSC209H5 Chapter Notes - Chapter 2: Entry Point, Dereference Operator, Memory Address

17 views7 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Using an address of one variable to another variable. Int i; i = 5 ; printf( "value of i: %d\n" , i); printf( "address of i: %p\n" , &i); // declare a pointer pt that will point to an int. // set pt to hold the address of i pt = &i; // print the value of the pointer (which is the address of i) printf( "value of pt: %p\n" , pt); // the pointer itself has an address, print that printf( "address of pt: %p\n" , &pt); // print the value in the address that is itself stored in pt printf( "value pointed to by pt: %d\n" , *pt); You can print the address using the & (ampersand) operator. ie. &i (as seen above) If you were to output the first two print statements of the program above, you would get. Address of i: 0x00007ffcb6464898 // or some address.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents