[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62649] fwrite function does not work properly

From: Aurelien Chiron
Subject: [Octave-bug-tracker] [bug #62649] fwrite function does not work properly with some value
Date: Fri, 17 Jun 2022 22:46:36 -0400 (EDT)


                 Summary: fwrite function does not work properly with some
                 Project: GNU Octave
               Submitter: ach411
               Submitted: Sat 18 Jun 2022 02:46:34 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: ach411
        Originator Email: 
             Open/Closed: Open
                 Release: 6.4.0
         Discussion Lock: Any
        Operating System: Microsoft Windows


Follow-up Comments:

Date: Sat 18 Jun 2022 02:46:34 AM UTC By: Aurelien Chiron <ach411>
This code snippet shows the issue. It should write 3x unsigned 16-bit values
(6 bytes) into a file. Instead, on my system, I end up with 8 bytes. The first
16-bit value appears to be correct but not the second one, nor the 3rd one.

fid = fopen("test_values", 'wt');
fwrite(fid, 2559, "uint16");
fwrite(fid, 2560, "uint16");
fwrite(fid, 2561, "uint16");

The resulting binary file "test_values" viewed by an Hexadecimal viewer:
ff 09 00 0d 0a 01 0d 0a

Windows being little endian, the first value written is correct: 0x09ff.
However, the second value should read 0x0a00, instead we have 3 bytes and it
looks like the byte 0x0d was incorrectly inserted in between 0x00 and 0x0a.
Same thing is true for the 3r value. 


Reply to this item at:


Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]