如何将 short int[] 转换为 char*?
short int test[4000];
char* test2;
我试过这个:
test2 = (char*)test[4000]
错误--> PTR 无效
最佳答案
像这样:
test2 = (char*)test;
test[4000]
表示数组 test
的第 4001st 项,而不是数组本身。
但总的来说,这不是一个好主意。至少,您的程序不能在大端系统和小端系统之间移植。不过,如果您正在为特定的微 Controller 编写代码,没关系。
关于c++ - 将 short int[] 转换为 char*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12134228/