Re: Question about strings and pointers

Valentin Haenel <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Dear Ananda

* Ananda Regmi <[email protected]> [100208]:
> I haven't tested your code but  I thought I will tell you the first thing
> that came in my mind.
> 
> I think you are trying to pass a python string to a c function as a c
> string.

Well, not exactly. I am trying to pass pointers into a c string.

> Try this to create the ctypes string in python and then pass pointer  with
> your function call.
> 
> import ctypes
> temp_str = 'this is the substring we would like to print'
> my_string = ctypes.create_string_buffer(temp_str, len(temp_str))

O.k. and how would i obtain pointers into the buffer? for example my_string[12]
again returns an object of type str.

V-



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.