Hello, I have this simple code which compiled and contain no error
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void add(int x, int y, int* result)
*result = x + y;
cout << result << endl;
However the program crashes when I ran it, but when I took out int* newptr; the program ran fine. Could someone tell me why it crashes? I have a feeling that it could be because result and newptr are both pointing at the same address, but I don't think it is correct.