Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Loading data from binary file genereted in C not C#

Discussion in 'Scripting' started by jomsa, Nov 18, 2015.

  1. jomsa

    jomsa

    Joined:
    Nov 10, 2013
    Posts:
    23
    I have a datafile filled with data generated by ancient program written in plain C. I've managed to load bits of it, but then i noticed i am writing entire struct as sizeof fwrite(struct,sizeof(struct),sizeof(struct)/sizeof(struct),fp);

    The struct is
    typedef struct {
    double value;
    double sub_value[9];
    }

    I am mostly interested in just getting the double value out of it. But how can i do this? Oh right, the struct is used as an array like struct[x][y];

    Ideas on how to read data out of the file?

    I've used BinaryReader() with readbyte succesfully read data from the file allready. But this struct has got me stuck.
     
  2. jomsa

    jomsa

    Joined:
    Nov 10, 2013
    Posts:
    23
    Figured it out. You simple iterate thourght it as if it was simple array.