Jump to content

  • Log In with Google      Sign In   
  • Create Account


chunkyguy

Member Since 09 Mar 2012
Offline Last Active Dec 05 2012 05:45 AM

#4998329 C++ pointer strangeness

Posted by chunkyguy on 06 November 2012 - 10:11 PM

You can just try is yourself by printing the pointers and everything should be clear:

printf("BEF: %p\n",reversed);
reversed = new char[strlen(src)+1];
printf("AFT: %p\n",reversed);

and in main()
printf("START: %p\n",reversed);
reverseString(original, reversed); //reversed should be assigned in here
printf("END: %p\n",reversed);

On my machine it prints something this:
START: 0x0
BEF: 0x0
AFT: 0x7fdc68c000e0
END: 0x0

And now read the answers posted above


PARTNERS