aboutsummaryrefslogtreecommitdiff
path: root/challenge-108
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-04-12 14:06:46 +0200
committerAbigail <abigail@abigail.be>2021-04-12 14:06:46 +0200
commitf02c5746861535f4471879d33ff63759bbcd6e9a (patch)
tree36d78deb67ee9dbc9d17a4630fe9c08035015d53 /challenge-108
parent1d687ed1911a31f57ca6714cc85b4eacf78dfbfe (diff)
downloadperlweeklychallenge-club-f02c5746861535f4471879d33ff63759bbcd6e9a.tar.gz
perlweeklychallenge-club-f02c5746861535f4471879d33ff63759bbcd6e9a.tar.bz2
perlweeklychallenge-club-f02c5746861535f4471879d33ff63759bbcd6e9a.zip
C solution for week 108, part 1
Diffstat (limited to 'challenge-108')
-rw-r--r--challenge-108/abigail/README.md1
-rw-r--r--challenge-108/abigail/c/ch-1.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-108/abigail/README.md b/challenge-108/abigail/README.md
index ef7fb8b526..98a4523d47 100644
--- a/challenge-108/abigail/README.md
+++ b/challenge-108/abigail/README.md
@@ -5,6 +5,7 @@ Write a script to declare a variable or constant and print it's
location in the memory.
### Solutions
+* [C](c/ch-1.c)
* [Perl](perl/ch-1.pl)
### Blog
diff --git a/challenge-108/abigail/c/ch-1.c b/challenge-108/abigail/c/ch-1.c
new file mode 100644
index 0000000000..0d1ad208bf
--- /dev/null
+++ b/challenge-108/abigail/c/ch-1.c
@@ -0,0 +1,21 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o
+ */
+
+int main (void) {
+ int i;
+ printf ("%lld\n", (long long) &i); /* %p is specific for printing */
+ /* memory addresses, but does this */
+ /* using hex numbers. So we cast */
+ /* the address to long long and */
+ /* print that. */
+ return (0);
+}