Le problème est de récupérer certains fichiers JPG à partir d'un fichier .raw.Mes IMG récupérés ne correspondent pas à l'original dans la récupération CS50
lorsque je lance check50 je suis "récupéré img ne correspond pas".
:)
existe.
:)
recover.c compile.
:)
poignées manque d'images médico-légale
:(
récupère correctement de – image récupérée ne correspond pas à
:(
récupère les images correctement – moyen image récupérée ne correspond pas à
:(
récupère correctement de – de 015.jpg pas trouvé
J'ai vraiment essayé d'identifier le problème et chaque fois que je ne parviens pas à identifier où le problème est, j'espère que quelqu'un peut et gi ve moi une paix de conseil.
#include <stdio.h>
#include <stdint.h>
int main(int argc, char *argv[]){
if(argc != 2){
fprintf(stderr, "Usage: ./recover image");
return 1;
}
//open file
FILE *inptr = fopen(argv[1], "r");
if (inptr == NULL){
fprintf(stderr, "Could not open %s.\n", argv[1]);
return 2;
}
int foundjpg = 0;
char filename[10];
int x=1;
//repeat until end of the card
while(x == 1){
//buffer
unsigned char buf[512];
x = fread(buf, 512, 1, inptr);
//read into buffer
fread(buf, 512, 1, inptr);
FILE *jpg = fopen(filename, "w");
//start of a new jpg?
if(buf[0]== 0xff && buf[1] == 0xd8 && buf[2] == 0xff && (buf[3] & 0xf0) == 0xe0){
if(jpg != NULL){// yes i found before
fclose(jpg);
sprintf(filename, "%03i.jpg" ,foundjpg);
foundjpg++;
jpg = fopen(filename, "w");
}
else{
sprintf(filename, "%03i.jpg" ,foundjpg);
jpg = fopen(filename , "w");
foundjpg++;
}
}
//already found a jpg?
if(jpg != NULL && foundjpg > 0){
fwrite(buf, 1, 512, jpg);
}
}
fclose(inptr);
// success
return 0;
}
Il existe un site désigné sur le réseau d'échange de pile pour [cs50.se]. – StoryTeller