The problem is that you process
p_newStr without initializint it, and
only performing pointer arithmetic on it. I
guess, that you wanted to see it as a string,
adding chars to it.
So first initialisze it:
char* p_newStr = newStr; // It was
unitinitalised, pointing at random location
Then note that
p_newStr = p_newStr +
str[i] means adding the value of the char
str[i], converted to int, to the pointer p_newStr.
That's pointer arithmetic. Replace this
*p_newStr++ = str[i]; // instead
of p_newStr = ...
and there is another one taking a char from the
*p_newStr++ = stack[top]; //
instead of p_newStr = ...
Finally, put an ending null terminator to the c
string you've built, just before your printf():
*p_newStr++ = 0;
Once these corrections made, the code produces
exactly the expected results.