硬code字节数组用C [英] hardcode byte array in C

查看:152
本文介绍了硬code字节数组用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调试网络应用程序。

我必须模拟一些,以使应用程序工作交换的数据。在C ++中,你可以这样做

I have to simulate some of the data exchanged in order for the application to work. In C++ you can do something like

char* myArray = { 0x00, 0x11, 0x22 };

不过,我似乎无法找到一个C相当于此语法。

However, I can't seem to find a C equivalent for this syntax.

基本上,我只是想填补硬codeD值的数组。

Basically I just want to fill an array with hard coded values.

推荐答案

您可以做同样的事情在C,但你应该申报类型的char [] 吧,没有的char * ,这样就可以得到它与的sizeof 运营商尺寸:

You can do the same thing in C, but you should declare it of type char[], not char*, so that you can get its size with the sizeof operator:

char myArray[] = { 0x00, 0x11, 0x22 };
size_t myArraySize = sizeof(myArray);  // myArraySize = 3

这篇关于硬code字节数组用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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