title: Converting hex String to structure
body: <p>I've got a file containing a large string of hexidecimal. Here's the first few lines:</p>
  
  <pre><code>0000038f
  0000111d
  0000111d
  03030303
  //Goes on for a long time
  </code></pre>
  
  <p>I have a large struct that is intended to hold that data:</p>
  
  <pre><code>typedef struct
  {
    unsigned int field1: 5;
    unsigned int field2: 11;
    unsigned int field3: 16;
    //Goes on for a long time
  }calibration;
  </code></pre>
  
  <p>What I want to do is read the above string and store it in the struct. I can assume the input is valid (it's verified before I get it).</p>
  
  <p>I've already got a loop that reads the file and puts the whole item in a string:</p>
  
  <pre><code>std::string line = "";
  std::string hexText = "";
  while(!std::getline(readFile, line))
  {
    hexText += line;
  }
  //Convert string into calibration
  //Convert string into long int
  long int hexInt = strtol(hexText.c_str(), NULL, 16);
  //Here I get stuck: How to get from long int to calibration...?
  </code></pre>