title: C++: Convert unsigned long long int into vector<char> and vice versa
body: <p>Can anyone tell me how to convert unsigned long long int into vector and vice versa.</p>
  
  <p>For converting from unsigned long long int to vector, I tried the following:</p>
  
  <pre><code>unsigned long long int x;
  vector&lt;char&gt; buf(sizeof(x));
  memcpy( &amp;buf[0], &amp;x, sizeof( x ) );
  </code></pre>
  
  <p>When I tested for x = 1234567890, it failed. But when I tried it for smaller values of x (say 1-100), it works... </p>
  
  <p>For converting vector to unsigned long long int, I used:</p>
  
  <pre><code>   unsigned long long int =  (unsigned long long int)buf[0];
  </code></pre>
  
  <p>Can anyone tell me how to do it.</p>