如何将无符号字符数组传递给 C++ 中的函数

How to pass unsigned char array to a function in C++?

本文关键字:C++ 函数 无符号 字符 数组      更新时间:2023-10-16
void GetKey(int date, unsigned char[] key)
{
}

我正在尝试传递无符号字符数组 t 一个函数,但我收到一个错误"预期为'('",其中"键"变量是。

只需移动括号:

void GetKey(int date, unsigned char key[])

但请注意,它基本上会退化为指针。

使用模板函数:

template<size_t N>
void GetKey(int date, unsigned char(&key)[N])
{
}