Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see actual value of a C++ string in CLion's debugger?

I'm using CLion on Linux and having difficulties with debugging. I evaluated an expression which ends up being a string, but the debugger is useless at showing me what the return value is, other than that it is a string. How do I see the actual value? (also note it doesn't even show the value of char values)

screenshot

like image 629
Earlz Avatar asked Feb 10 '17 13:02

Earlz


1 Answers

With gdb you can print std::string by below 2 methods.

  1. p mystr.c_str() -this can be used to print value of type std::string.
  2. p *(char**) 0x7f8fbb7a9c20 -this works for a memory with type std::string.
like image 143
leoram111 Avatar answered Sep 19 '22 22:09

leoram111