title: C++ obtaining the short number after a string in an array of bytes
body: <p>Hey so following this <a href="https://stackoverflow.com/questions/6966462/method-to-get-to-the-middle-of-the-file-for-binary-search">Question</a></p>
  
  <p>I've gotten stuck again, and yeah I've tried looking through the web and through my textbook. I know its probably bad posting another question so soon, but I'm truly stumped on this problem. So anyways...</p>
  
  <p>The next part of the assignment asks me to find the age of the person, this age is located on the next byte after the name. Basically if the name was "Bob" it would be </p>
  
  <pre><code>[L][u][k][e][\0][\0][1][5]
  </code></pre>
  
  <p>where all names with even number of characters get 2 null characters to make it even and then the next two bytes store a <code>short</code> integer. At the moment I have tried looking at the string length and then adding more onto the length before placing that onto the offset, but it doesnt seem to work</p>
  
  <pre><code>    if (name.length() % 2 != 0) {
          offset += (name.length());
          age = *((short*)foo+offset);
          cout &lt;&lt; age &lt;&lt; "\n";
      } else {
          offset += (name.length());
          age = *((short*)foo+offset);
          cout &lt;&lt; age &lt;&lt; "\n";
      }
  </code></pre>