aboutsummaryrefslogtreecommitdiff
path: root/challenge-029/dave-jacoby/perl5/ch-2.pl
blob: 87de84f6efecfc2d710347a04ad6724755b6049c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env perl

# Task #2
# Write a script to demonstrate calling a C function.
# It could be any user defined or standard C function.

# another instance where I'm copying and pasting from other sources
# and cannot really claim that I wrote this.

# https://metacpan.org/pod/Inline

use Inline C;

print "9 + 16 = ", add( 9, 16 ), "\n";
print "9 - 16 = ", subtract( 9, 16 ), "\n";

__END__
__C__
int add(int x, int y) {
  return x + y;
}
 
int subtract(int x, int y) {
  return x - y;
}