the error occur because there is 0 in my byte array . Do i need to encode it then?
On Wed, Jun 14, 2017 at 9:16 PM, andrey mirtchovski <mirtchov...@gmail.com> wrote: > can you show us a complete example with a stub C function? in > particular the conversion to (*C.char) from unsafe.Pointer(&data[0]) > should work. compare the first four bits at that address with the > first four bits you're receiving on the C side. they should be > identical. e.g.: https://play.golang.org/p/sqP12_nJNF > > On Wed, Jun 14, 2017 at 7:54 AM, <aditi.bhiwaniw...@gmail.com> wrote: > > I have a byte array of image in golang , i have to pass this array to my > C > > function as char* . I did he following , > > data, err := ioutil.ReadAll(out.Body) > > str := fmt.Sprintf("%s",data) > > s:=C.main1(C.CString(str)) > > s:=C.main1((*C.char)(unsafe.Pointer(&data[0]))) > > but both the technique doesn't work. All i m receiving in my C function > is > > some garbage value of length 4. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to golang-nuts+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.