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.