- int convert_usercode_to_fpga(char *buf)
- {
- int i = 0;
- int j = 0;
- char tempa[RX_DATA_LEN] = {0};
- char tempb[RX_DATA_LEN] = {0};
- char *p;
- char usercode[][RX_DATA_LEN] = {
- {"gray"},
- {"colo"},
- {"ramp"},
- {NULL}
- };
- p = usercode;
- if (!buf)
- {
- return -1;
- }
- strcpy(tempa,buf);
- while (*(p + i))
- {
- strcpy(tempb,(const char *)(p + i));
- j = strcmp(tempa,tempb);
- if (j == 0)
- {
- return i;
- }
- i ++;
- }
- return -3;
- }
以上程序执行strcpy(tempb,(p + i));后就死了。
如果把二维数组usercode定义为char不会死,但是数组里德数据会被改写。
请问是什么原因?
谢谢!
|