4
votes

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

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 Answers

2
votes

Surely you mean:

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