1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need some help !!! :)

Discussion in 'C++' started by Soul, Oct 3, 2010.

  1. Soul

    Soul New Member

    Joined:
    Sep 23, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Romania
    Ok, i m new in C++ so i have 1 problem

    i have this code in c++ and i have to figure why i have 8 as a result
    Code:
    #include <iostream>
    using namespace std;
    
    int* f(int* a){
       int b = 2;
       (*a) += b;
       return a;
    }
    int main (){
       int a = 5;
       (*f(&a))++;
       cout << a << endl; 
       return 0;
    }
    
    thank you .
     

Share This Page