Added Rust to C++ example

This commit is contained in:
Petr Kozelka
2018-09-11 02:29:57 +02:00
parent a2ddf21e48
commit 4798ecc622
4 changed files with 34 additions and 0 deletions

11
rust-to-cpp/src/main.rs Normal file
View File

@@ -0,0 +1,11 @@
extern crate libc;
extern {
fn triple_input(input: libc::c_int) -> libc::c_int;
}
fn main() {
let input = 4;
let output = unsafe { triple_input(input) };
println!("{} * 3 = {}", input, output);
}

View File

@@ -0,0 +1,4 @@
extern "C"
int triple_input(int input) {
return input * 3;
}