Read the Serial port data and print into text file

I'm trying to print the Serial data packet value in text file, the data packet coming from Arduino due board,

Arduino code:

                    void setup()
                  {
                       Serial.begin(9600)
                       uint16_t packet[8];
                   }

                 void loop()
                 {
                    for(int i=0 ;i<8;i++)
                     {
                         Packet[i]=0x0A31+i;
                    
                         Serial.println(packet[i]);
                     }
                 }



c++ code:
            //  Read function only
                read()
                 {

                  uint16_t data[8];
                  DWORD bytesRead;
                 Readfile(hcomm, &data , sizeof(data) , &bytesRead,Null);

                 File*fp;
                  fp=("c:\\data.txt","a+");
                  for(int i=o;i<7;i++)
                  {
                       fprintf(fp,"%x/t",data[i];
                  }
                       fprintf(fp,"\n");
                }

The Arduino output is :A31 A32 A33 A34 ..... (each data is 12 bit )this is correct , and then i read data from Serial port and print into text file the output is : A31A3 2A3 3A34..(i'm not getting porper 12 bit manner...)
so how to change my read function.......to print proper ( 12bit ) data in the text file

                       uint16_t packet[8];

This is useless. The variable goes out of scope immediately.

                  for(int i=o;i<7;i++)

You are initializing i to o. What value is in o?

to print proper ( 12bit ) data in the text file

There are no 12 bit data types on any Arduino. You are printing as text, so the number of bits isn't relevant.