string confusion CPP

Started by
6 comments, last by The C modest god 17 years, 6 months ago
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.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
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).
It also shows that npos is a very large number.
I didnt find anything that reminds the "foo" I assigned to Name.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Do you have any sort of optimizations turned on? Optimizations can mess with the debugger quite a bit.
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 :)
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.
[size=2]aliak.net
I use visual CPP 2003.
I don't use optimization and I go past the command.
To be more accurate, when I go past the Name = "foo"; command, the value showen is {???}.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
You were right, I can see the string value in a _Ptr member inside the string structure.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.

This topic is closed to new replies.

Advertisement