MSVC 2005 question

I just got MSVC 2005, and I'm having some problems.

I ran the following test:
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
      int i;
      std::string s;

      std::cout << "Enter in a string: " << std::flush;
      std::getline(std::cin,s);
      i = s.length();

      std::cout << "You entered: " << s;
      std::cout << " which is " << i << " characters long" << std::endl;
      return 0;
}

Simple program which compiles and runs just fine.  The problem is when I run it in the debugger.  If I input in the string "hello there", the debugger variable watch shows the string as having the value: "€PD"  
Also, the variable i doesn't show up on the variable watch at all.  The only variables which show up are argc, argv, and s.  

Anyone have any insight here?
LVL 5
lwinkenbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rajeev_devinCommented:
There is some bug with the compiler.
It should work fine.
lwinkenbAuthor Commented:
Is it possible I have a project setting that is off?
rajeev_devinCommented:
>> Is it possible I have a project setting that is off?
Are you using the free trial version of MSVC 2005 ?
Then this is obvious.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

AlexFMCommented:
Click on the + sign near string variable in the Watch window. One of string members is char* pointer which must show right value.
lwinkenbAuthor Commented:
>> Are you using the free trial version of MSVC 2005 ?
I don't think so.  I'm using a version I got through my school.

>> Click on the + sign near string variable in the Watch window. One of string members is char* pointer which must show right value.
Strangely enough, there is no + sign.  It acts as if string is a primitive type that doesn't have any members.
lwinkenbAuthor Commented:
Here is some more information.  When I run the following:

int main(int argc, char *argv[])
{
      char str[] = "hello there my friend";

      std::cout << str << std::endl;
      return 0;
}

The debugger shows str as the following:  -            str      0x0012ff38 "œùŸhellHÿ"      char [22]
str[0]   -100
str[1]   -7
str[2]   -97
str[3]   7
str[4]   104
str[5]   101
str[6]   108
str[7]   108
str[8]   72
str[9]   -1
str[10]  18
str[11]  0
str[12]  122
str[13]  -79
str[14]  65
str[15]  0
str[16]  109
str[17]  121
str[18]  32
str[19]  102
str[20]  -68
str[21]  -84

The debugger is clearly having problems.  Is it possible that I have a bad installation?  The debugger works just fine with C# applications.
lwinkenbAuthor Commented:
Well, I figured out the problem finally.  When I turn off the compiler optimization /02, then everything works fine.  
CetusMODCommented:
PAQed with points refunded (250)

CetusMOD
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.