thanks, that does it.<br><br>
-brent<br><br><div><span class="gmail_quote">On 12/1/06, <b class="gmail_sendername">Chris Perkins</b> <<a href="mailto:chrisperkins99@gmail.com">chrisperkins99@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 12/1/06, Brent Pedersen <<a href="mailto:bpederse@gmail.com">bpederse@gmail.com</a>> wrote:<br>> hi, i've just been tinkering with pyrex, trying to do this (below).<br>> but it segfaults on the sscanf line in pyscanf.
<br>> what am i doing wrong? is this more involved than my naive approach?<br>><br>> thanks,<br>> -brent<br>><br>> ##############################<br>> # pyscanf.pyx<br>><br>> cdef extern from "
stdio.h":<br>> int sscanf (char *,char *,...)<br>><br>> def pyscanf(char * str):<br>> cdef char * q<br>> cdef char * s<br>> cdef int my_int<br>> cdef float my_float<br>> sscanf(str,"%s %s %i %f",q,s,&my_int,&my_float)
<br>> return [q,s,my_int,my_float]<br>><br>><br>> ####### run with ###########<br>> from pyscanf import pyscanf<br>> print pyscanf("asdf asdf 123 12.22")<br><br>You need to allocate space for p and s. sscanf tries to copy "asdf"
<br>in to the memory location that q points to, but you have left it<br>uninitialized. Same for s.<br><br>Chris Perkins<br></blockquote></div><br>