- I don't know what is wrong.
- It tells address of local variable returned.
#include<iostream>
using namespace std;
int *myfunc(int *ptrB);
int main(){
int *a, b;
cout << "give b :" << endl;
cin >> b;
a = myfunc(&b);
cout << "a is :" << *a << endl;
return 0;
}
int *myfunc(int *ptrB) {
int a;
a= (*ptrB) * (*ptrB);
*ptrB = a;
return &a;
}
Aucun commentaire:
Enregistrer un commentaire