github.com/notti/nocgo@v0.0.0-20190619201224-fc443047424c/steps/2_go/test/main.go (about)

     1  package main
     2  
     3  // #include <stdio.h>
     4  // #include <stdlib.h>
     5  // #include <string.h>
     6  import "C"
     7  
     8  import "unsafe"
     9  
    10  func main() {
    11  	cs := []byte("Hello\000 world\000")
    12  	C.puts((*C.char)(unsafe.Pointer(&cs[0])))
    13  	C.fputs((*C.char)(unsafe.Pointer(&cs[0])), C.stdout)
    14  	C.putc('a', C.stdout)
    15  	C.strcat((*C.char)(unsafe.Pointer(&cs[0])), (*C.char)(unsafe.Pointer(&cs[0])))
    16  	C.puts((*C.char)(unsafe.Pointer(&cs[0])))
    17  }