title: Ctypes: passing string as argument from Python to C
body: <p>Anyone familiar with Ctypes who can help me?</p>
  
  <p>I am trying to call a C function (actually a class method) from python. My issue is passing a string as argument. To keep it short, I wont copy the C code, because everything works fine there. But here is my python class:</p>
  
  <pre><code>from ctypes import cdll, c_char_p
  clib = cdll.LoadLibrary('./libfoo.so')
  
  class Session(object):
      def __init__(self):
          self.obj = clib.tunnel_init()
  
      def start(self, user_input):
          clib.tunnel_start.restype = c_char_p
          clib.tunnel_start.argtypes = [c_char_p]
          a = c_char_p(user_input)
          result = clib.tunnel_start(self.obj, a)
          return str(result)
  </code></pre>
  
  <p>When I run:</p>
  
  <pre><code>if __name__ == "__main__":
      hello = Session()
      msg = hello.start("test")
      print(msg)
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>TypeError: bytes or integer address expected instead of str instance
  </code></pre>
  
  <p>Seems like my argument is treated like a string, not as a pointer. How can I fix it? </p>
  
  <p>Any help would be very much appreciated!</p>