title: Python ctypes: initializing c_char_p()
body: <p>I wrote a simple C++ program to illustrate my problem:</p>
  
  <pre><code>extern "C"{
      int test(int, char*);
  }
  
  int test(int i, char* var){
      if (i == 1){
          strcpy(var,"hi");
      }
      return 1;
  }
  </code></pre>
  
  <p>I compile this into an so.  From python I call:</p>
  
  <pre><code>from ctypes import *
  
  libso = CDLL("Debug/libctypesTest.so")
  func = libso.test
  func.res_type = c_int
  
  for i in xrange(5):
      charP = c_char_p('bye')
      func(i,charP)
      print charP.value
  </code></pre>
  
  <p>When I run this, my output is:</p>
  
  <pre><code>bye
  hi
  hi
  hi
  hi
  </code></pre>
  
  <p>I expected:</p>
  
  <pre><code>bye
  hi
  bye
  bye
  bye
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Thanks.</p>