HERE IS THE CODE EXPLAINING HOW POINTERS STORE ADDRESS AND HOW TO DISPLAY ADDRESS OF VARIABLE AND VALUE OF VARIABLE
CODE :-
#include <iostream>
#include <string>
using namespace std;
int main() {
string food = "Pizza"; // A string variable
string *ptr = &food; // A pointer variable that stores the address of food
// Output the value of food
cout << food << "\n";
// Output the memory address of food
cout << &food << "\n";
// Output the memory address of food with the pointer
cout << *ptr << "\n";
return 0;
}
HOW TO CODE :-
coding is easy but only thing you need to do is practice. Do lot of practice of different codes with your compiler . if you have any questions about your code ask me with mail kghate8121@gmail.com
use #askque
THANK YOU.
FOLLOW US
- twitter :- https://twitter.com/KrishnaGhate8
- Instagram :- https://www.instagram.com/krishna.ghate/?hl=en
Comments
Post a Comment