Reading in binary file and outputting to another binary file

So im trying to read a binary file into an array and then output that array into another file, which should therefor get me 2 identical files. But they are different files Why would this be? #include <stdio.h> int main() { unsigned int buffer[1000000]; FILE *in; in = fopen("file.bin", "rb"); fread(buffer, sizeof(buffer), 1, in); fclose(in);… Read More Reading in binary file and outputting to another binary file

Python3, binary data diffrent representation from what i need

I have to add an image to a database, so I open the image as binary and it stores it this way: b’\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x01\x03\x00\x00\x00%\xdbV\xca\x00\x00\x00\x03PLTE\x00\x00\x00\xa7z=\xda\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\x00\nIDAT\x08\xd7c`\x00\x00\x00\x02\x00\x01\xe2!\xbc3\x00\x00\x00\x00IEND\xaeB`\x82′ However I need it to be strored this way: 0x89504e470d0a1a0a0000000d494844520000000100000001010300000025db56ca00000003504c5445000000a77a3dda0000000174524e530040e6d8660000000a4944415408d76360000000020001e221bc330000000049454e44ae426082 It is my first ever time working with binary files so there is probably something basic I’m not understanding. This is my… Read More Python3, binary data diffrent representation from what i need

Reading integer from file through function in c returns wrong value

I’m trying to read a bunch of information about a player from a binary file in c through the following code: #include <stdio.h> #include <stdlib.h> #include <string.h> // structure joueur typedef struct Joueur { char nom[20]; int num_lieu; int liste_objet[10]; }Joueur; // question a void sauvegarder_jeu(char* nom_partie, Joueur* joueur) { // ouverture du fichier FILE… Read More Reading integer from file through function in c returns wrong value