views:

81

answers:

3

I am trying to figure out a problem in my c++ code and have DDD to debug with on a Sun machine. I am required to use strings per some standard we have. But whenever DDD encounters a string variable, it always comes up as being empty. I want to remember having the same trouble using CVD before on an SGI.
Short of re-writing my code to remove string is there anything else I could try/use?

+1  A: 

Have a look here

They solve it by implementing a helper function that can be used by gdb (should also work for DDD as it uses gdb)

epatel
A: 
p variablename.c_str()

or

display variablename.c_str()
Steve Lazaridis
A: 

Basically, you need to create a wrapper function that prints out your string, by passing it a memory address:

void gs(string &s) { cout << s << endl; }

and then in gdb:

call gs(somevariable)

Reference

Seamus