diff --git a/ch2-cgo/ch2-03-cgo-types.md b/ch2-cgo/ch2-03-cgo-types.md index ab5a188..3380fb3 100644 --- a/ch2-cgo/ch2-03-cgo-types.md +++ b/ch2-cgo/ch2-03-cgo-types.md @@ -322,8 +322,9 @@ type SliceHeader struct { ```go /* -static char arr[10]; -static char *s = "Hello"; +#include +char arr[10]; +char *s = "Hello"; */ import "C" import ( @@ -347,7 +348,7 @@ func main() { s0Hdr.Len = int(C.strlen(C.s)) sLen := int(C.strlen(C.s)) - s1 := string((*[31]byte)(unsafe.Pointer(&C.s[0]))[:sLen:sLen]) + s1 := string((*[31]byte)(unsafe.Pointer(C.s))[:sLen:sLen]) } ```