title: String of Bytes to Byte array c++
body: <p>Im trying to make function that takes this pattern string :</p>
  <pre><code>&quot;07 C5 8F E1 FD CA 8C E2 D4 FD BC E5 03 C6 8F E2&quot;
  </code></pre>
  <p>to return this BYTE array</p>
  <pre><code>BYTE pattern[] = { 0x07, 0xC5, 0x8F, 0xE1, 0xFD, 0xCA, 0x8C, 0xE2, 0xD4, 0xFD, 0xBC, 0xE5, 0x03,  0xC6, 0x8F, 0xE2};
  </code></pre>
  <p>What i tried:</p>
  <pre><code>BYTE strPatternToByte(std::string pattern, int len)
  {
      std::vector&lt;std::string&gt; tokens;
      std::string token;
      std::istringstream tokenStream(pattern);
      while(std::getline(tokenStream, token, ' '))
      {
          tokens.push_back(token);
      }
      BYTE somePtr[len];
      for ( int i=0 ; i &lt; len ; i++)
      {
          somePtr[i] = '0x' +  tokens[i];
      }
  
      return somePtr;
  }
  </code></pre>
  <p>but the line to convert to pattern of bytes didn't work for me,</p>
  <pre><code>somePtr[i] = (byte) tokens[i];
  </code></pre>
  <p>is there a way in c++ to automatically parse them into bytes or something like in java?</p>