std :: vector <uchar>到char *数据丢失

时间:2015-05-03 07:55:23

标签: c++ vector casting type-conversion

我使用cv::Matimage/jpeg编码为vector<uchar>char *现在我想将该矢量转换为vector<uchar> buf; // print buf to stdout to ensure that data is valid here for (auto c : buf) cout << c << endl; // cast vector to char char *ch = reinterpret_cast<char*>(buf.data()); // print out value of char pointer for(int i = 0; ch[i] != '\0'; i++) printf("log: %c\n", ch[i]); 类型。

std::vector<T>

向量上的for循环取自this question。 从char *buf的演员阵容取自this question

现在问题是在类型转换期间似乎有一些数据丢失。鉴于????包含有效数据,我始终只获得ch打印的值/** Check if obj is a T, including base classes. */ template <class T> inline bool is_a(const basic &obj) { return dynamic_cast<const T *>(&obj) != 0; }

这里发生了什么想法?

0 个答案:

没有答案
相关问题