Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what is difference between pointer *p and variable p

+1 vote
asked Aug 17, 2018 by ganesh2000s (190 points)

2 Answers

+1 vote
answered Aug 18, 2018 by Ethan Alexander Lee (580 points)
selected Aug 19, 2018 by ganesh2000s
 
Best answer

#include <iostream>
using namespace std;

int main(){
    int Apple = 25;
    int *Pointer = &Apple;
    
    cout<<Apple<<endl;
    cout<<Pointer<<endl;
    cout<<*Pointer<<endl;
    
    return 0;
}
 


Output:
25
0x7ffc39e1726c
25
 


* before a variable's name gets the value of that variable.
That is if it is defined as a pointer.

0 votes
answered Sep 4, 2018 by anonymous

Pointer is "special" variable that stores "address" in the memory, this address can be another variable address, if so, you can access it's value by using operator '*'

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...