Did you mean to put newchar; instead? The former creates a *single* character with the value of 2 (some unprintable thing), not an array of 2. You might need more space for your sprintf anyway to include the terminating null and such, I don't remember if %x adds 0x or anything when you print like that.
Somebody told me this and I am agree with this alternative..
You cannot store the result of sprintf call into the location pointed to by c in the first place because you only allocated a single char, initialising it with a value of 2. Perhaps you wanted to use new char instead, but that would still be rather unnecessary. Instead, you might as well just use the standard C++-specific facilities, e.g.,