使用 C++ 中的 cout 以十六进制格式打印 OpenCL cl_uchar?

发布于 2024-12-19 08:55:55 字数 486 浏览 2 评论 0原文

我正在尝试验证我的指针是否就位,并且想以十六进制格式打印 cl_uchar(无符号字符 OpenCL 类型)的值。我尝试过:

cout << “数据矩阵0,3 =”<< clMatrixPerm->data_matrix->elements[4] << endl;

cout << “数据矩阵0,3 =”<<十六进制 << clMatrixPerm->data_matrix->elements[4] << endl;

其中 clMatrixPerm->data_matrix->elements[4] 是要打印的数组中的数据。在这两种情况下,数据矩阵 0,3 = 之后都没有输出。我能够使用 printf 的解决方法,因此我知道数据已正确分配,但如果可能的话,我想使用 cout 打印它。

I'm trying to verify my pointers are in place and I'd like to print the value of a cl_uchar (unsigned char OpenCL type) in hex format. I tried:

cout << "Data matrix 0,3 = " << clMatrixPerm->data_matrix->elements[4] << endl;

and

cout << "Data matrix 0,3 = " << hex << clMatrixPerm->data_matrix->elements[4] << endl;

where clMatrixPerm->data_matrix->elements[4] is the data in the array to be printed. In both cases there was no output after Data matrix 0,3 =. I was able to use a workaround with printf so I know the data is being assigned correctly, but I'd like to print it using cout if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ〆星空下的拥抱 2024-12-26 08:55:55

简单的

cout << "Data matrix 0,3 = " << hex << static_cast<unsigned int>(clMatrixPerm->data_matrix->elements[4]) << endl;

Simple

cout << "Data matrix 0,3 = " << hex << static_cast<unsigned int>(clMatrixPerm->data_matrix->elements[4]) << endl;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文