如何在C / C ++中定义字节数组? [英] How to define byte array in C/C++?

查看:1378
本文介绍了如何在C / C ++中定义字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在C / C ++中定义字节数组

我搜索网并找到各种例子,所以很困惑哪一个是正确的: -

其中一个是哪一个是正确的吗?

  unsigned   char  bytes [] = 0x43,0x4d,0x30,0x30,0x0f,0X0D}; 

const char data3 [] = {0x43,0x4d,0x30,0x30 ,0xf0,0x0D};

char 数据[ 4 ] = CM00;

解决方案

所有它们是有效的(当然,在第一个中,缺少开放的大括号)。


参见基本类型 [ ^ ]和下标 [ ^ ]。


字节测试[5 ] = {0xb4,0xaf,0x98,0x1a,0xB5执行};

i have to define byte array in C/C++
I searched net and found various examples,so confused which one is correct:-
Out of these which one is correct?

unsigned char bytes[]=0x43,0x4d,0x30,0x30,0x0f,0x0D};

const char data3[]={0x43,0x4d,0x30,0x30,0xf0,0x0D};

char data[4]="CM00";

解决方案

All of them are valid (of course, in the first one, the open curly brace is missing).


See fundamental types[^] and subscripts[^].


byte test[5]={0xb4,0xaf,0x98,0x1a,0xb5};


这篇关于如何在C / C ++中定义字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆