Convert from unsigned char array to long c

I read the longest from the binary into an unsigned char buffer using fread.

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

unsigned char buffer[sizeof(long)]; fread(buffer, sizeof(long), 1, my_file); 

thanks!

+4
source share
1 answer

Surely you mean:

 long buffer; fread(&buffer, sizeof(long), 1, my_file); 
+2
source

Source: https://habr.com/ru/post/1345429/


All Articles