Created
April 13, 2014 04:17
-
-
Save 1000copy/10568997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#include <stdlib.h> | |
*/ | |
import "C" | |
import ("fmt") | |
func Random() int { | |
return int(C.random()) | |
} | |
func Seed(i int) { | |
C.srandom(C.uint(i)) | |
} | |
func main(){ | |
fmt.Println("random from cgo:",Random()); | |
} | |
// run : $go run cgo_demo.go | |
// output : random from cgo: 1804289383 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment