Sign in to follow this  
Sfpiano

After clearing string, it gets filled with ???

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this