From: Francis Cianfrocca Date: 2007-05-01T16:19:12+09:00 Subject: Re: sprintf can not work in ruby c source? ------=_Part_292584_33083657.1178003951336 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 5/1/07, Haoqi Haoqi wrote: > > here is my simple test: > where is my mistake?? > > #include "ruby.h" > #include "stdio.h" > static VALUE > tests(){ > char *s1="a "; > char *s2=" b"; > char *buf; > sprintf(buf,"%s after %s",s1,s2); > printf(buf); > return Qnil; > } > void Init_hello(){ > rb_define_global_function("tests",tests,0); > } Um, you realize you're writing right into a random memory location? If you're not an experienced C programmer, you may want to reconsider your project to write a Ruby extension. ------=_Part_292584_33083657.1178003951336--