Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

string confusion CPP

This topic is 4372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a class with a string member, lets say string Name; I do Name="something"; in one method. In the second method I do Name = "foo"; When I call the second method, the moment I press F10 on Name = "foo"; I see in the debugger that Name = {???} instead of the required string. Why does this happen? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
The SC++L types might not be prettified by your debugger. Look at what's inside (including the internal character buffer, which should contain the correct value).

Share this post


Link to post
Share on other sites
Do you have any sort of optimizations turned on? Optimizations can mess with the debugger quite a bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
It also shows that npos is a very large number.
Relatively speaking, std::string::npos is a very large number :)

Share this post


Link to post
Share on other sites
Do you stop *at* Name = "foo", or do you go past it and still not see the name assigned. Also, which debugger are you using?

And string::npos is a static value that doesn't change throughout the life of the application. There is only one npos variable that is used to check for "not found" conditions in various string algorithms.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!