我该怎么做?
uint_fast8_t array1[100];
uint_fast8_t array2[100];
void get_a(bool which_one)
{
uint_fast8_t *array[] = which_one ? &array2 : &array1; //doesn't work
}
这会引发错误“无法将 uint_fast8_t(*)[100] 转换为 uint_fast8_t *[]”
最佳答案
因为它不是指针而是指针数组
uint_fast8_t *array = which_one ? array2 : array1;
或者
uint_fast8_t *array[] = {which_one ? &array2 : &array1}
关于c++ - 使用 if (? operator) 语句传递带指针的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56466072/