0

My code works as I get all 0-49 images that look beautiful to me. After days of working on this, I really would appreciate any advice as to why the checker is saying my code failed the last three checks. I can't see why the checker is not seeing the images I am. I read previous posts on similar problem but don't see the issue with my code. Thanks

:) recover.c exists.

:) recover.c compiles.

:) handles lack of forensic image

:( recovers 000.jpg correctly
    000.jpg not found

:( recovers middle images correctly
    001.jpg not found

:( recovers 049.jpg correctly
    049.jpg not found

    {
        printf(" Use one file only.  Usage: ./recover filename\n");
        return 1;
    }
       // Declare pointer and open argv file in read mode
    FILE *praw = fopen(argv[1], "r");

    if (praw == NULL)
    {
        // Send message that argv file could not be opened for reading
        printf("File could not be opened for reading\n");
        return 1;
    }
     //  Count number of jpegs we have found and saved in jpeg files
    int jpnum = 0;
    //  Pass count or block count to help find error
    int passno = 0;
    // Set up for new jpeg files and file names
    FILE *img;
    // Set up an array for the 512 bytes that will be stored
    BYTE arrchunk[bytes_allocated];
     while (fread(arrchunk, bytes_allocated, 1, praw))
    {
        // Check to see if we have found a jpeg, if not keep reading
        if (jpeg(arrchunk[0], arrchunk[1], arrchunk[2], arrchunk[3]) == true)
        {
        passno++;
            if (passno == 1)
            {
                 // If new jpeg, close previous file and increase jpeg number. // 
                 // Make the new jpegfilename and open
                char nf[8];
                sprintf(nf, "%03i.jpeg", jpnum++);
                img = fopen(nf, "w");
                if (img == NULL)
                    return 1;
                fwrite(arrchunk, bytes_allocated, 1, img);passno++;
          
1

How is the file name extension supposed to be spelled, precisely???

sprintf(nf, "%03i.jpeg", jpnum++);

vs:

000.jpg not found

Close doesn't get the job done. ;-)

1
  • I could hug you!!!! A small error makes for a big mistake. – NENENE Oct 6 '20 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .