[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MSVC 2005 question

Posted on 2006-03-27
9
Medium Priority
?
320 Views
Last Modified: 2010-04-24
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?
0
Comment
Question by:lwinkenb
8 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16308182
There is some bug with the compiler.
It should work fine.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16308286
Is it possible I have a project setting that is off?
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16308513
>> 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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 48

Expert Comment

by:AlexFM
ID: 16310725
Click on the + sign near string variable in the Watch window. One of string members is char* pointer which must show right value.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16311966
>> 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.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16314668
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.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16317138
Well, I figured out the problem finally.  When I turn off the compiler optimization /02, then everything works fine.  
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 16517985
PAQed with points refunded (250)

CetusMOD
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question