gpt4 book ai didi

C++ std::vector 已填充,但未显示数据

转载 作者:太空宇宙 更新时间:2023-11-03 10:20:51 24 4
gpt4 key购买 nike

这是我的代码:

std::string message(m_buff.begin(), m_buff.end());

std::cout << "Client wrote sth!" << std::endl;
std::cout << message.c_str() << std::endl;

如果我在最后一行设置断点,启动调试器并查找 m_buff var,有一些数据,但没有显示出来。

这是数据(来自调试器):

m_buff  [0x00000400](0x00,0x08 '',0x22 '"',0x00,0x57 'W',0x6f 'o',0x57 'W',0x00,0x03 '',0x03 '',0x05 '',0x34 '4',0x30 '0',0x36 '6',0x38 '8',0x78 'x',0x00,0x6e 'n',0x69 'i',0x57 'W',0x00,0x45 'E',0x44 'D',0x65 'e',0x64 'd',0x3c '<',0x00,0x00,0x00,0x05 '',0x6c 'l',0x19 '',0x1c '',0x04 '',0x46 'F',0x47 'G',0x47 'G',0x47 'G',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,...,...)  std::vector<unsigned char,std::allocator<unsigned char> >

最佳答案

假设调试器显示的数据是正确的,您的消息缓冲区中似乎有一些二进制零。

请记住,二进制0 ('\0') 用于指示字符串的结尾。因此,由于 m_buff 的第一个元素为零,字符串的有效长度为 0。

你也许应该迭代 m_buff 并将所有字节打印为十六进制序列 - 或者过滤掉任何 0 字符(也许还有其他不可打印的东西 - 取决于一点取决于你的确切意图)。

关于C++ std::vector<uint8> 已填充,但未显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5774388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com