问题是访问指针数组的每个地址正在将我的数据合并到后续数据
#include <stdio.h>
#include <string.h>
/* String are NULL terminated, you might have read comments in question */
unsigned char mydata1[] = {0x41, 0x42, 0x43, 0x00};
unsigned char mydata2[] = {0x44, 0x45, 0x46, 0x00};
unsigned char mydata3[] = {0x47, 0x48, 0x49, 0x4A, 0x00};
/* Here I have used a NULL terminated array so that we can traverse
* even if we do not know the length of array
*/
unsigned char *charPtr[] =
{
mydata1,
mydata2,
mydata3,
NULL
};
int main()
{
int i;
for (i = 0; charPtr[i] != NULL; i++) {
printf("%s\n", charPtr[i]);
}
return 0;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句