从无符号字符数组转换为长c

时间:2021-03-01 22:29:57

I read a long from a binary file into an unsigned char buffer using fread.

我使用fread将一个二进制文件中的long读入一个无符号字符缓冲区。

Now I would like to get the long. How do I do it?

现在我想要长时间。我该怎么做?

unsigned char buffer[sizeof(long)];

fread(buffer, sizeof(long), 1, my_file);

thanks!

谢谢!

1 个解决方案

#1


2  

Surely you mean:

肯定你的意思:

long buffer;
fread(&buffer, sizeof(long), 1, my_file);

#1


2  

Surely you mean:

肯定你的意思:

long buffer;
fread(&buffer, sizeof(long), 1, my_file);