简体   繁体   中英

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?

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.

Also, I may be allocating memory for this function from python as a numpy array and calling it through ctypes. Is there a preferred way to allocate a byte array in numpy?

Is np.zeros(size, dtype=np.byte) the normal way, if the corresponding C type is char , for example?

The most common way is using a char array. However, it really depends on the needs of the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM