mardi 28 juillet 2015

Getting erronous output

following code gives output 10 on machine and 0 on ideone. What can be the reason ?

#include<iostream>
using namespace std;

int *fun()
{
    int x = 10;
    return &x;
}

int main()
{
    *(fun()) = 30;
    cout << *(fun());
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire