Keil C51单片机 字符串数组问题高手来啊
ucharxdataCC_Commend[400];ucharxdataCC_string1[57]={"*<Long><320></Long><Result><Opty...
uchar xdata CC_Commend[400];
uchar xdata CC_string1[57]={"*<Long><320></Long><Result><Optype><AA></Optype><Metno><"};
uchar xdata CC_string2[19]={"></Metno><spaces><"};
uchar xdata CC_string3[17]={"></spaces><Eno><"};
uchar xdata CC_string4[16]={"></Eno><Stime><"};
uchar xdata CC_string5[18]={"></Stime><Tlong><"};
uchar xdata CC_string6[17]={"></Tlong><Cost><"};
uchar xdata CC_string7[18]={"></Cost><Bankno><"};
uchar xdata CC_string8[103]={"></Bankno><SenseNo><0001></SenseNo><Ptype><22></Ptype><Prebuy><2011-11-01 16:13:12></Prebuy></Result>#"};
uchar xdata CC_metno[6]={0x31,0x31,0x31,0x31,0x31,0x31};
uchar xdata CC_space[2]={0x32,0x32};
uchar xdata C_eno[6]={0x33,0x33,0x33,0x33,0x33,0x33};
uchar xdata CC_time[14]={0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34};
uchar xdata CC_tlong[4]={0x35,0x35,0x35,0x35};
uchar xdata CC_cost[4]={0x36,0x36,0x36,0x36};
uchar xdata CC_bank[8]={0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x37};
把上面的字符串和数组全部放进 CC commend数组里面数字和字符串交叉合成 一个字符串一个数字串 这样合成下谢谢 展开
uchar xdata CC_string1[57]={"*<Long><320></Long><Result><Optype><AA></Optype><Metno><"};
uchar xdata CC_string2[19]={"></Metno><spaces><"};
uchar xdata CC_string3[17]={"></spaces><Eno><"};
uchar xdata CC_string4[16]={"></Eno><Stime><"};
uchar xdata CC_string5[18]={"></Stime><Tlong><"};
uchar xdata CC_string6[17]={"></Tlong><Cost><"};
uchar xdata CC_string7[18]={"></Cost><Bankno><"};
uchar xdata CC_string8[103]={"></Bankno><SenseNo><0001></SenseNo><Ptype><22></Ptype><Prebuy><2011-11-01 16:13:12></Prebuy></Result>#"};
uchar xdata CC_metno[6]={0x31,0x31,0x31,0x31,0x31,0x31};
uchar xdata CC_space[2]={0x32,0x32};
uchar xdata C_eno[6]={0x33,0x33,0x33,0x33,0x33,0x33};
uchar xdata CC_time[14]={0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34};
uchar xdata CC_tlong[4]={0x35,0x35,0x35,0x35};
uchar xdata CC_cost[4]={0x36,0x36,0x36,0x36};
uchar xdata CC_bank[8]={0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x37};
把上面的字符串和数组全部放进 CC commend数组里面数字和字符串交叉合成 一个字符串一个数字串 这样合成下谢谢 展开
2个回答
展开全部
看到了你前面的提问,用sprintf函数是可以的,但是数据部分要转为整形,sprintf没有uchar类型。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
uchar xdata CC_Commend[400];
uchar xdata CC_string1[57]={"*<Long><320></Long><Result><Optype><AA></Optype><Metno><"};
uchar xdata CC_string2[19]={"></Metno><spaces><"};
uchar xdata CC_string3[17]={"></spaces><Eno><"};
uchar xdata CC_string4[16]={"></Eno><Stime><"};
uchar xdata CC_string5[18]={"></Stime><Tlong><"};
uchar xdata CC_string6[17]={"></Tlong><Cost><"};
uchar xdata CC_string7[18]={"></Cost><Bankno><"};
uchar xdata CC_string8[103]={"></Bankno><SenseNo><0001></SenseNo><Ptype><22></Ptype><Prebuy><2011-11-01 16:13:12></Prebuy></Result>#"};
uchar xdata CC_metno[6]={0x31,0x31,0x31,0x31,0x31,0x31};
uchar xdata CC_space[2]={0x32,0x32};
uchar xdata C_eno[6]={0x33,0x33,0x33,0x33,0x33,0x33};
uchar xdata CC_time[14]={0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34};
uchar xdata CC_tlong[4]={0x35,0x35,0x35,0x35};
uchar xdata CC_cost[4]={0x36,0x36,0x36,0x36};
uchar xdata CC_bank[8]={0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x37};
{
int i = 0;
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string1, CC_metno[0], CC_metno[1], CC_metno[2], CC_metno[3], CC_metno[4], CC_metno[5]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string2, CC_space[0], CC_space[1]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string3, C_eno[0], C_eno[1], C_eno[2], C_eno[3], C_eno[4], C_eno[5]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string4, CC_time[0], CC_time[1], CC_time[2], CC_time[3], CC_time[4], CC_time[5], CC_time[6], CC_time[7], CC_time[8], CC_time[9], CC_time[10], CC_time[11], CC_time[12], CC_time[13]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string5, CC_tlong[0], CC_tlong[1], CC_tlong[2], CC_tlong[3]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string6, CC_cost[0], CC_cost[1], CC_cost[2], CC_cost[3]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string7, CC_bank[0], CC_bank[1], CC_bank[2], CC_bank[3], CC_bank[4], CC_bank[5], CC_bank[6], CC_bank[7]);
i+=sprintf(CC_Commend+i, "%s", CC_string8);
}
uchar xdata CC_string1[57]={"*<Long><320></Long><Result><Optype><AA></Optype><Metno><"};
uchar xdata CC_string2[19]={"></Metno><spaces><"};
uchar xdata CC_string3[17]={"></spaces><Eno><"};
uchar xdata CC_string4[16]={"></Eno><Stime><"};
uchar xdata CC_string5[18]={"></Stime><Tlong><"};
uchar xdata CC_string6[17]={"></Tlong><Cost><"};
uchar xdata CC_string7[18]={"></Cost><Bankno><"};
uchar xdata CC_string8[103]={"></Bankno><SenseNo><0001></SenseNo><Ptype><22></Ptype><Prebuy><2011-11-01 16:13:12></Prebuy></Result>#"};
uchar xdata CC_metno[6]={0x31,0x31,0x31,0x31,0x31,0x31};
uchar xdata CC_space[2]={0x32,0x32};
uchar xdata C_eno[6]={0x33,0x33,0x33,0x33,0x33,0x33};
uchar xdata CC_time[14]={0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34,0x34};
uchar xdata CC_tlong[4]={0x35,0x35,0x35,0x35};
uchar xdata CC_cost[4]={0x36,0x36,0x36,0x36};
uchar xdata CC_bank[8]={0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x37};
{
int i = 0;
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string1, CC_metno[0], CC_metno[1], CC_metno[2], CC_metno[3], CC_metno[4], CC_metno[5]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string2, CC_space[0], CC_space[1]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string3, C_eno[0], C_eno[1], C_eno[2], C_eno[3], C_eno[4], C_eno[5]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string4, CC_time[0], CC_time[1], CC_time[2], CC_time[3], CC_time[4], CC_time[5], CC_time[6], CC_time[7], CC_time[8], CC_time[9], CC_time[10], CC_time[11], CC_time[12], CC_time[13]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string5, CC_tlong[0], CC_tlong[1], CC_tlong[2], CC_tlong[3]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string6, CC_cost[0], CC_cost[1], CC_cost[2], CC_cost[3]);
i+=sprintf(CC_Commend+i, "%s%c%c%c%c%c%c", CC_string7, CC_bank[0], CC_bank[1], CC_bank[2], CC_bank[3], CC_bank[4], CC_bank[5], CC_bank[6], CC_bank[7]);
i+=sprintf(CC_Commend+i, "%s", CC_string8);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询