I don't know if this is the problem, but the implementation of strreplace contains a local static char array newstringza (OT: what's with all the za's all over the code?), which it fills with the new constructed string. At the end, it returns this array as a char*. I don't remember all the intricacies of C++, but I think this may be a problem (I'll write a quick program to see). A quick fix would be to change the last line (line 92) from:
return newstringza;
to:
return strdup(newstringza);
which allocates a buffer the correct size, copies the string to the buffer, and returns a pointer to the buffer.
Or, you could try moving the declaration of the char[] outside the function (just before it should work).
It's probably not a good idea to return a pointer to a local variable in any case. Anyone with more extensive C++ experience want to comment (I've been doing Java too long...).
|