simple-c-code

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 2 Imported by: 0

README

simple-c-code example

A very simple example to show you how to write a c function in go.

GitHub Webpage

THE C CODE

Here is a very simple c code example,

int Add(int a, int b){
    return a+b;

IMPLEMENT WITH GO

To implement using go use import "C",

package main

//int Add(int a, int b){
//    return a+b;
//}
import "C"
import "fmt"

func main() {
    a := C.int(10)
    b := C.int(20)
    c := C.Add(a, b)
    fmt.Println(c) // 30
}

RUN

go run simple-c-code.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL