C++ Modify Pointers Last Updated : 05 Dec, 2022 Comments Improve Suggest changes Like Article Like Report Prerequisite: Pointer in C++ Pointers are an essential part of the C++ language. It allows us to store the memory address of a variable. One thing to note here is that if we change the value that a pointer is pointing to, then the value of the original variable also changes. Now, let's check the approach we are going to use. Approach: In the below example, we will first declare and initialize a string variable. Then, we will store the address of the string variable in a pointer. Finally, we will modify the value that the pointer is pointing to and print all the values associated with the program to the screen. Example: C++ // C++ program to demonstrate the // process of modifying a pointer #include <iostream> #include <string> using namespace std; int main() { string website = "ABC"; string* p = &website; cout << "The value of the variable: " << website << "\n"; cout << "The memory address of the variable: " << p << "\n"; cout << "The value that the pointer is pointing to: " << *p << "\n"; *p = "GeeksforGeeks"; cout << "The new value that the pointer is pointing to: " << *p << "\n"; cout << "The memory address of the variable: " << p << "\n"; cout << "The new value of the variable: " << website << "\n"; return 0; } OutputThe value of the variable: ABC The memory address of the variable: 0x7ffef00579f0 The value that the pointer is pointing to: ABC The new value that the pointer is pointing to: GeeksforGeeks The memory address of the variable: 0x7ffef00579f0 The new value of the variable: GeeksforGeeks In the above output, we can see that the value the pointer was pointing to changed from ABC to GeeksforGeeks. Consequently, the value of the website variable also changed from ABC to GeeksforGeeks. And, this doesn't affect the address of the website just changes the value inside it. Comment More infoAdvertise with us Next Article C++ Modify Pointers S sriparnxnw7 Follow Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 cpp-pointer Practice Tags : CPP Similar Reads C++ Pointers A pointer is a variable that stores the address of another variable. Pointers can be used with any data type, including basic types (e.g., int, char), arrays, and even user-defined types like classes and structures.Create PointerA pointer can be declared in the same way as any other variable but wit 8 min read C++ Vector of Pointers Prerequisites Pointers in C++Vectors in C++ Vector of pointers are vectors that can hold multiple pointers. Each pointer within a vector of pointers points to an address storing a value. We can use the vector of pointers to manage values that are not stored in continuous memory. How to Create Vector 6 min read Pointers in Objective-C In Objective-C, Pointers are the variables that hold the memory address of another variable. You must have declared the pointer variable before its use. The size of the pointer depends on the architecture of the system. The pointer variable can be defined as a char, int, float, double, or any other 5 min read void Pointer in C A void pointer is a pointer that has no associated data type with it. A void pointer can hold an address of any type and can be typecasted to any type.Example of Void Pointer in CC// C Program to demonstrate that a void pointer // can hold the address of any type-castable type #include <stdio.h 3 min read Pointer vs Array in C Most of the time, pointer and array accesses can be treated as acting the same, the major exceptions being:  1. the sizeof operator sizeof(array) returns the amount of memory used by all elements in the array sizeof(pointer) only returns the amount of memory used by the pointer variable itself 2. 1 min read Pointers vs Array in C++ Arrays and pointers are two derived data types in C++ that have a lot in common. In some cases, we can even use pointers in place of arrays. But even though they are so closely related, they are still different entities. In this article, we will study how the arrays and pointers are different from e 3 min read C++ Pointer Operators Prerequisite: Pointers in C++ A pointer variable is a variable that stores the address of another variable or in other a pointer variable points to the variable whose address is stored inside it. Syntax: int *pointer_name; There are mainly two types of Pointer operators mainly used: Address of opera 2 min read Dereference Pointer in C We know that the pointer variable can store the memory address in C language and in this article, we will learn how to use that pointer to access the data stored in the memory location pointed by the pointer. What is a Pointer? First of all, we revise what is a pointer. A pointer is a variable that 4 min read Applications of Pointers in C Pointers in C are variables that are used to store the memory address of another variable. Pointers allow us to efficiently manage the memory and hence optimize our program. In this article, we will discuss some of the major applications of pointers in C. Prerequisite: Pointers in C. C Pointers Appl 4 min read Array of Pointers in Objective-C A pointer is a variable that stores the address of another variable. We use pointers because, with the help of pointers the memory is accessed efficiently, it saves memory space, and execution time is faster as compared to the use of normal variables using stack memory because pointers store their m 5 min read Like