🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C++ Notes
Topic #70

Modify Pointers


Modify the Pointer Value

You can also change the pointer's value. But note that this will also change the value of the original variable:

Example

    string food = "Pizza";
string* ptr = &food;

// Output the value
    of food (Pizza)
cout << food << "\n";

// Output the memory address
    of food (0x6dfed4)
cout << &food << "\n";

// Access the memory
    address of food and output its value (Pizza)
cout << *ptr << "\n";

// Change the value of the pointer
*ptr = "Hamburger";

//
    Output the new value of the pointer (Hamburger)
cout << *ptr << "\n";

//
    Output the new value of the food variable (Hamburger)
cout << food << "\n";

Want to go beyond the notes?

Join CodingNow 2.0's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Modify Pointers – FAQs

Quick answers about learning Modify Pointers in C++.

This free note from CodingNow 2.0 explains Modify Pointers in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, including Modify Pointers, is 100% free with no signup required.
With focused practice, most students grasp Modify Pointers in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now