samedi 6 août 2016

Function pointer to a function that returns pointer

This is my c code giving error, please let me know what is wrong about it

int *doubleNum(int *a, int *b)
{
    int c = (*a) + (*b); 
    return &c;
}

int main()
{
    int a = 2, b = 2;
    int (*p)(int*, int*);
    p = &doubleNum;
    int *c = (*p)(&a, &b);

    cout << (*c);
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire