在 C 中将 int 转换为字节数组?

标签 c

我需要将存储在 int 中的十进制数转换为字节数组(也就是存储在无符号字符数组中)。

有什么线索吗?

最佳答案

或者如果你知道自己在做什么:

int n = 12345;
char* a = (char*)&n;

关于在 C 中将 int 转换为字节数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3447735/

相关文章:

c - Strncpy(字符串C编程)第二次表现不佳

c - 为什么该函数可以正常使用 float 而不能使用 double?

c - 函数中的读取和指向结构的指针

c - 通过堆栈推送的指针引用传递

C - 从文件中读取句子到 malloc 创建的字符串数组中

在C中以相反的顺序将链表的元素复制到另一个链表

c - strcpy 的段错误,即使指针有指针

代码审查 : finding </body> tag reverse search on a non-null terminated char str

c - 如何以字节为单位获取字符串大小?

c++ - curl_easy_perform() 失败 : failed FTP upload (the STOR command) error