What if you could change data anywhere just by knowing where it lives in memory?
Why Address and dereference operators? - Purpose & Use Cases
Imagine you have a list of friends' phone numbers written on paper. To call a friend, you have to look up their number every time manually. If you want to change a number, you must rewrite it everywhere it appears. This is like handling data without pointers in C.
Manually copying or passing data everywhere is slow and error-prone. If you want to update a value, you must find and change every copy. This wastes time and can cause mistakes, especially with large data or complex programs.
Address and dereference operators let you work with the location of data instead of copies. You can pass around the address (pointer) and change the original data directly. This saves time, memory, and reduces errors.
int x = 10; int y = x; // copy value // changing y does not affect x
int x = 10; int *p = &x; // store address *p = 20; // change original x through pointer
It enables efficient data sharing and modification by using memory addresses directly.
Think of a remote control (pointer) that lets you change the TV (data) without moving the TV itself.
Manual data copying is slow and error-prone.
Address operator (&) gets the location of data.
Dereference operator (*) accesses or changes data at that location.