title: Reading a large structured binary file in Julia
body: <p>I have a <strong>large binary file containing identical records</strong> with this memory layout:</p>
  
  <pre><code># Julia code
  struct Event
      ia::Int32
      ig::Int32
      Eg::Float64
      Tg::Float64
      xn::Float64
      yn::Float64
      zn::Float64
  
      # uninitialized constructor
      Event() = new()
  end
  </code></pre>
  
  <p>How can I translate this C++ code in Julia?</p>
  
  <pre><code>// C++ code
  struct Event
  {
    int32_t ia;  
    int32_t ig;  
    double  Eg; 
    double  Tg;
    double  xn; 
    double  yn;
    double  zn;
  };
  
  // ... compute event_count
  
  std::ifstream in(filename,std::ifstream::binary);
  std::vector&lt;Event&gt; array(event_count);
  
  in.read((char*)array.data(), event_count*sizeof(Event)); // &lt;- Julia way: how to?
  </code></pre>