Why does my pointer have a different value after I've dereferenced it in main vs when Ive dereferenced it within my own custom function?
It's probably something really simple but I can't figure it out. Here is the code below:
int *addNumbers(int a, int b);
int main()
{
    int no1 = 1;
    int no2 = 3;
    int no3 = 8;
    int *answer = &no3;
answer = addNumbers(no1, no2);
std::cout << answer << std::endl;
std::cout << *answer << std::endl;
/* Why does this second cout line not give the same 
answer as the second cout statement
 in the addNumbers function? */
}
int *addNumbers(int a, int b)
{
    int *resultPntr;
    int result = a+b;
    resultPntr = &result;
    std::cout << resultPntr << std::endl;
    std::cout << *resultPntr << std::endl;
    return resultPntr;
}
I thought dereferencing resultPntr and answer would give the same value??
 
     
     
    