字节数组赋值 [英] byte array assignment
本文介绍了字节数组赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
byte test[4];
memset(test,0x00,4);
test[]={0xb4,0xaf,0x98,0x1a};
上述代码在']'令牌前给我一个错误。
任何人都可以告诉我这种类型的作业有什么问题?
the above code is giving me an error expected primary-expression before ']' token. can anyone tell me whats wrong with this type of assignment?
推荐答案
/ p>
What Ben and Chris are saying is.
byte test[4]={0xb4,0xaf,0x98,0x1a};
如果你想在运行时做,你可以使用memcpy来做这项工作。 p>
If you want to do it at run time, you can use memcpy to do the job.
byte startState[4]={0xb4,0xaf,0x98,0x1a};
byte test[4];
memcpy(test, startState, sizeof(test));
这篇关于字节数组赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文