说我有密码:
std::string str = "random";
function(str);
void function (std::string str)
{
  std::cout << str << std::endl;
}如果我在gdb中遍历这段代码,然后进入函数并执行p str,它会打印出类似于这个\362\241的内容,但是cout会在屏幕上打印正确的字符串random。以前有人见过这个吗?如果是的话,我该怎么办?我是在gdb中错误地使用了print命令,还是它与编译器如何解释字符串有关?
发布于 2011-01-28 16:13:04
是否使用调试信息编译了二进制文件?就像g++ -g test.cpp
我公司正在显示正确的信息:
(gdb) p s
$2 = {static npos = <optimized out>, 
  _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x804b014 "Hello world"}}https://stackoverflow.com/questions/4830279
复制相似问题