简体   繁体   English

在 C 中表示字节数组的最常用方法是什么?

[英]What is the most common way to represent a byte array in C?

Would we use char , signed char , unsigned char or import some header for a byte type?我们会使用charsigned charunsigned char还是导入一些 header 作为byte类型?

My code is going to be seen/used by other C developers and I want to use whatever standard they're most likely used to seeing.我的代码将被其他 C 开发人员看到/使用,我想使用他们最有可能看到的任何标准。

Also, I may be allocating memory for this function from python as a numpy array and calling it through ctypes.另外,我可能会从 python 为这个 function 分配 memory 作为 Z2EA9510C37F7F62F89E49CB41F7 数组并调用它。 Is there a preferred way to allocate a byte array in numpy?在 numpy 中分配字节数组是否有首选方法?

Is np.zeros(size, dtype=np.byte) the normal way, if the corresponding C type is char , for example?例如,如果相应的 C 类型是charnp.zeros(size, dtype=np.byte)是正常方式吗?

The most common way is using a char array.最常见的方法是使用 char 数组。 However, it really depends on the needs of the code.但是,这实际上取决于代码的需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中表示图灵机无限磁带的最有效方法是什么? - What is the most efficient way to represent the infinite tape of a Turing machine in Python? 返回列表列表中最常见项目列表的方法是什么? - What is a way to return a list of most common item in a list of lists? 在Django的调试和生产中配置静态文件的最常用方法是什么 - What is the most common way to configure static files in debug and production for Django 检查 NumPy 数组中是否存在值的最有效方法是什么? - What is the most efficient way to check if a value exists in a NumPy array? 标准化 4D 数组的最有效方法是什么? - What is the most efficient way to Normalize a 4D array? 访问存储在 NumPy 数组中的树节点的最有效方法是什么 - What is most efficient way to access nodes of a tree stored in a NumPy array 在另一个数组中找到一个 numpy 数组的行列的最有效方法是什么? - What is the most efficient way of finding the ranks of one numpy array in another? 在Numpy数组中匹配模板的最有效方法是什么? - What is the most efficient way to match templates in a Numpy array? 在pandas中使用布尔数组索引对象的最惯用的方法是什么? - What is the most idiomatic way to index an object with a boolean array in pandas? 在 Python 中绘制 3d 数组的最有效方法是什么? - What is the most efficient way to plot 3d array in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM