如何在c++中声明byte*(字节数组)
How to Declare byte* ( byte array ) in c++?
如何在c++中声明字节*(字节数组)以及如何在函数定义中定义为参数?
当我在
下面声明like时函数声明:
int Analysis(byte* InputImage,int nHeight,int nWidth);
获取错误:"byte" undefined
c++中没有byte
类型。你之前应该用typedef
。就像
typedef std::uint8_t byte;
c++ 11中的,或者
typedef unsigned char byte;
在c++ 03。表示字节的c++类型是unsigned char
(或char
的其他符号风格,但如果您希望它作为纯字节,unsigned
可能是您所追求的)。
然而,在现代c++中,您不应该使用原始数组。如果数组是运行时大小,使用std::vector<unsigned char>
;如果数组是静态大小N
,使用std::array<unsigned char, N>
(c++ 11)。您可以通过(const)引用将它们传递给函数,如下所示:
int Analysis(std::vector<unsigned char> &InputImage, int nHeight, int nWidth);
如果Analysis
不修改数组或其元素,则执行以下操作:
int Analysis(const std::vector<unsigned char> &InputImage, int nHeight, int nWidth);
相关文章:
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何将字节数组元素替换为修改的十六进制 ASCII 符号?
- 基于字节数组生成静态范围整数值
- 将字节数组转换为带有字节序问题的指针
- 找到一种有效的方法,在 2 个巨大的缓冲区上执行 MAX,每字节字节
- 使用 stbi_write_png,如何将 0 和 1 的矩形字节数组转换为单色 png 文件?
- 字节数组初始化会导致 DirectX 崩溃
- 使用 swig 追加到字节数组
- C++ 替换字节数组中项的顺序
- QDataStream 读取和写入的字节数比 QFile::length() 报告要多
- 如何从保存在 Java 中C++的字节数组中读取数字?
- 如何通过libpq c api插入字节的数组
- i2c中的字节指针数组
- 以 C++ 为单位递增 16 字节字符数组
- new[] 一个包含构造函数的字节对象数组没有错,对吧?
- 创建未知长度的字节/字符数组
- 我如何将bitset转换为字节/uint8数组
- C++ <--> C# 修改字节编组数组
- 将m个字节的数组拆分为n个字节的块
- c++到c#:有3个元素的字节指针数组等于什么?