I've been having some problems lately where I cannot view the value of a std::string while I am debugging my program.
I am working in Visual Studio 2008 and developing a 64-bit executable. When I debug my project, I can put
1 2 3 4 5 6 7 8
int main(int argc, char* argv[])
{
string strLogFile = "C:\\Log\\run1.txt";
// rest of code //
return 0;
}
and as soon as the first line is executed, if I mouse over the variable strLogFile, it says that it is a <Bad Ptr>. If I put it in one of the Watch windows, it has:
1 2
Name Value Type
strLogFile <Bad Ptr> std::basic_string<char,std::char_traits<char>,std::allocator<char> >
If I create an entirely new project that has just the code below in it.
Are you compiling for release? There should be three text boxes under the menu bar. One says the build configuration, the other the target platform, and the third is a search box.
If you're compiling for release, the debugger reports garbage.
Unfortunately that is not the case :( I have Debug selected. Debug is also selected as the Active solution configuration: and Configuration field in the Configuration Manager.
Debugger to Launch: Local windows Debugger
Command: $(TargetPath)
Command Arguments: (n/a)
Working Directory: (n/a)
Attach: No
Debugger Type: Auto
Environment: (n/a)
Merge Environment: Yes