SSCS1021 Lecture Notes - Lecture 3: Memory Management, Ampersand, Memory Address

4 views28 pages
21 May 2023
Department
Course
Professor

Document Summary

Pointers in c are easy and fun to learn. Some c programming tasks are performed more easily with pointers, and other tasks, such as dynamic memory allocation, cannot be performed without using pointers. So it becomes necessary to learn pointers to become a perfect c programmer. Let"s start learning them in simple and easy steps. As you know, every variable is a memory location and every memory location has its address defined which can be accessed using ampersand (&) operator, which denotes an address in memory. Consider the following example, which prints the address of the variables defined . #include int main () { int var1; char var2[10]; printf("address of var1 variable: %x\n", &var1 ); printf("address of var2 variable: %x\n", &var2 ); return 0; A pointer is a variable whose value is the address of another variable, i. e. , direct address of the memory location.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions