我在这里问的问题很容易解决。代码工作正常,但这个警告让我烦恼!
//initailize array elements
char ZeroA[6] = {0xC0,0x07,0x40,0x04,0xC0,0x07,};
char OneA[6] = {0x80, 0x04, 0xC0, 0x07, 0x00, 0x04,};
char TwoA[6] = {0x40, 0x07, 0x40, 0x05, 0xC0, 0x05,};
char ThreeA[6] = {0x40, 0x05, 0x40, 0x05, 0xC0, 0x07,};
char FourA[6] = {0x80, 0x03, 0x00, 0x02, 0x80, 0x07,};
char FiveA[6] = {0xC0, 0x05, 0x40, 0x05, 0x40, 0x07,};
char SixA[6] = {0xC0,0x05,0x40,0x05,0x40,0x07,};
char SevenA[6] = {0x40,0x04,0x40,0x03,0xC0,0x00,};
char EightA[6] = {0xC0,0x07,0x40,0x05,0xC0,0x07,};
char NineA[6] = {0xC0,0x05,0x40,0x05,0xC0,0x07,};
char TenA[6] = {0x00,0x01,0x80,0x03,0x00,0x01,};
int *mCount; //address holder
char var = 4; //Just random number for illustration
int *XYZ[11]={&ZeroA,&OneA,&TwoA,&ThreeA,&FourA,&FiveA,&SixA,&SevenA,&EightA,&NineA,&TenA};
mCount = XYZ[Var];
答案 0 :(得分:0)
随着amine.ahd的延续,mCount需要成为一个char指针。
x = [1,2,3]
y = [0,*x,4,5]
插入几行代码进行测试。虽然它印有白色字符,但似乎有效。更重要的是,没有编译警告。
答案 1 :(得分:-2)
ZeroA
,因此有一个指向char
元素数组的指针。
&ZeroA
保存指向数组ZeroA
的指针的地址,因此要保留它,您需要char **
在您的示例中执行此操作的正确方法如下:
char *XYZ[11]={ZeroA,OneA,TwoA,ThreeA,FourA,FiveA,SixA,SevenA,EightA,NineA,TenA};