I've been stuck for days with this problem. My recover program creates 15 jpgs but none of them show.  

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature. 

But byte 1 is always 0 instead of 0xff.  I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

    int main(void)
     {
    //open raw data file 
    FILE* rawfile = fopen("card.raw", "r");
    
     // buffer to hold 512 bytes from fread 
        typedef uint8_t  BYTE;
        BYTE buffer[512]; 
        char title[7];
        FILE* img = NULL;
        int search = 0; 
        int picnumber = 0; 

      while (feof (rawfile) == 0)
      {
          fread(&buffer, 512, 1, rawfile);

       //check for next jpeg signature 
           
                
           if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
              {
                  

              //close current
                if ( search > 0)
                {
                 fclose(img);
                } 
                //open new JPG and how to display file name 
                  sprintf(title, "%03d.jpg", picnumber); 
                  img = fopen(title, "a" );
                  
                 //write from buffer to new jpg, 
                fwrite(&buffer, 512, 1, img);
                picnumber++;
                search = 1;
              }
          else if (search > 0)
             {  
            fwrite(&buffer, 512, 1, img);   
             }
      }

      
}