Sign in to follow this  

string confusion CPP

This topic is 4093 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
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
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

This topic is 4093 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.

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