After clearing string, it gets filled with ???
I have a string that contains: "models/monsters/imp/imp"
When I call string.clear(), or try to assign anything else to the string, it gets filled with garbage and shows up as ??? in the debugger.
spontanous i can only think of the clear function to create an empty string placing the pointer to this empty string in the string-object. as your debugger most probably examines the string the old pointer points to it will show as ???, meaning the pointer is no more valid.
try examining the new string pointer after the clear function.
try examining the new string pointer after the clear function.
More than likely, your std::string implementation knows when it's getting a string of length 0, just deletes any string it currently has, doens't reset the pointer to zero, and just sets teh length field to 0 and ignores the pointer until you add something into the string.
In other words, it might be working perfectly. (edit: oh yeah. And this is the reason there's an abstraction barrier around the internals. You're not supposed to care what goes on inside.)
In other words, it might be working perfectly. (edit: oh yeah. And this is the reason there's an abstraction barrier around the internals. You're not supposed to care what goes on inside.)
yeah... until you need a 'char*' to feed it into a printf or such a thing... and bang you've got a SEGF because the pointer is nonense instead of set to NULL... hm... that's a rather lame implementation though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement