title: Binary String to Hex c++
body: <p>When changing a Binary string to Hex, I could only do it to a certain size based off of the answers I found. But I want to change MASSIVE Binary strings into their complete Hex counterpart in a more efficient way than this which is the only way I've come across that does it completely:</p>
  
  <pre><code>for(size_t i = 0; i &lt; (binarySubVec.size() - 1); i++){
      string binToHex, tmp = "0000";
      for (size_t j = 0; j &lt; binaryVecStr[i].size(); j += 4){
          tmp = binaryVecStr[i].substr(j, 4);
          if      (!tmp.compare("0000")) binToHex += "0";
          else if (!tmp.compare("0001")) binToHex += "1";
          else if (!tmp.compare("0010")) binToHex += "2";
          else if (!tmp.compare("0011")) binToHex += "3";
          else if (!tmp.compare("0100")) binToHex += "4";
          else if (!tmp.compare("0101")) binToHex += "5";
          else if (!tmp.compare("0110")) binToHex += "6";
          else if (!tmp.compare("0111")) binToHex += "7";
          else if (!tmp.compare("1000")) binToHex += "8";
          else if (!tmp.compare("1001")) binToHex += "9";
          else if (!tmp.compare("1010")) binToHex += "A";
          else if (!tmp.compare("1011")) binToHex += "B";
          else if (!tmp.compare("1100")) binToHex += "C";
          else if (!tmp.compare("1101")) binToHex += "D";
          else if (!tmp.compare("1110")) binToHex += "E";
          else if (!tmp.compare("1111")) binToHex += "F";
          else continue;
      }
      hexOStr &lt;&lt; binToHex;
      hexOStr &lt;&lt; " ";
  }
  </code></pre>
  
  <p>Its thorough and absolute, but slow.</p>
  
  <p>Is there a simpler way of doing this?</p>