title: Converting from unsigned Char* to unsigned int
body: <p>When I do the following, I get this error: </p>
  
  <p><b>../src/Sample.cpp:19: error: cast from \u2018UINT8*\u2019 to \u2018UINT8\u2019 loses precision</b></p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  typedef unsigned char UINT8;
  typedef unsigned int UINT32;
  
  #define UNUSED(X) X=X
  
  int main() {
      UINT8 * a = new UINT8[34];
      UINT32 b = reinterpret_cast&lt;UINT8&gt;(a);
  
      UNUSED(b);
  
      return 0;
  }
  </code></pre>
  
  <p>How would I go about solving this. Keep in mind I am not trying to convert string to unsigned long, rather converting char* (the ADDRESS value ) to int. </p>
  
  <p>Thanks</p>
  
  <p>Solution:</p>
  
  <p>Turns out that this problem has to do with the pointer size. On a 32 bit machine, the pointer size is 32 bit, and for 64 bit machine is of course 64. The above wont work on a 64 bit machine, but will on a 32 bit machine. This will work on a 64 bit machine. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdint.h&gt;
  
  using namespace std;
  
  typedef  uint8_t UINT8;
  typedef int64_t UINT32;
  
  #define UNUSED(X) X=X
  
  int main() {
      UINT8 * a = new UINT8[34];
      UINT32 b = reinterpret_cast&lt;UINT32&gt;(a);
      UNUSED(b);
  
      return 0;
  }
  </code></pre>