github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/doc/progs/cgo3.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package print
     6  
     7  // #include <stdio.h>
     8  // #include <stdlib.h>
     9  import "C"
    10  import "unsafe"
    11  
    12  func Print(s string) {
    13  	cs := C.CString(s)
    14  	C.fputs(cs, (*C.FILE)(C.stdout))
    15  	C.free(unsafe.Pointer(cs))
    16  }
    17  
    18  // END OMIT