From ca6b65b7e299fca5763a5875deeabbe09b3a1fe7 Mon Sep 17 00:00:00 2001
From: thib <tempo2riz@gmail.com>
Date: Tue, 22 Jun 2021 21:48:36 +0200
Subject: [PATCH] template

---
 exam2/ex1/Makefile | 10 ++++++++++
 exam2/ex1/main.c   | 29 +++++++++++++++++++++++++++++
 exam2/ex2/Makefile | 10 ++++++++++
 exam2/ex2/main.c   | 29 +++++++++++++++++++++++++++++
 exam2/ex3/Makefile | 10 ++++++++++
 exam2/ex3/main.c   | 29 +++++++++++++++++++++++++++++
 exam2/ex4/Makefile | 10 ++++++++++
 exam2/ex4/main.c   | 29 +++++++++++++++++++++++++++++
 exam2/ex5/Makefile | 10 ++++++++++
 exam2/ex5/main.c   | 29 +++++++++++++++++++++++++++++
 10 files changed, 195 insertions(+)
 create mode 100644 exam2/ex1/Makefile
 create mode 100644 exam2/ex1/main.c
 create mode 100644 exam2/ex2/Makefile
 create mode 100644 exam2/ex2/main.c
 create mode 100644 exam2/ex3/Makefile
 create mode 100644 exam2/ex3/main.c
 create mode 100644 exam2/ex4/Makefile
 create mode 100644 exam2/ex4/main.c
 create mode 100644 exam2/ex5/Makefile
 create mode 100644 exam2/ex5/main.c

diff --git a/exam2/ex1/Makefile b/exam2/ex1/Makefile
new file mode 100644
index 0000000..478f28e
--- /dev/null
+++ b/exam2/ex1/Makefile
@@ -0,0 +1,10 @@
+main: main.o
+	gcc -o $@ $< -fsanitize=address -fsanitize=leak
+
+main.o: main.c 
+	gcc -c -Wall -Wextra -pedantic -fsanitize=address -fsanitize=leak $<
+
+clean:
+	rm -f *.o main
+
+rebuild: clean main
\ No newline at end of file
diff --git a/exam2/ex1/main.c b/exam2/ex1/main.c
new file mode 100644
index 0000000..45422d4
--- /dev/null
+++ b/exam2/ex1/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _element {
+  char c;
+  struct _element *next;
+} element;
+
+int main(int argc, char **argv) {
+
+  // read user input
+  char str[16];
+  scanf("%s", str);
+  int len = strlen(str);
+  // cli args
+  if (argc == 1) {
+    printf("need more arguments");
+    return EXIT_FAILURE;
+  }
+
+  for (int i = 0; i < argc; i++) {
+    if (!strcmp(argv[i], "-c")) {
+      // do stuff with atof/atoi (argv[++i])
+    }
+  }
+
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/exam2/ex2/Makefile b/exam2/ex2/Makefile
new file mode 100644
index 0000000..478f28e
--- /dev/null
+++ b/exam2/ex2/Makefile
@@ -0,0 +1,10 @@
+main: main.o
+	gcc -o $@ $< -fsanitize=address -fsanitize=leak
+
+main.o: main.c 
+	gcc -c -Wall -Wextra -pedantic -fsanitize=address -fsanitize=leak $<
+
+clean:
+	rm -f *.o main
+
+rebuild: clean main
\ No newline at end of file
diff --git a/exam2/ex2/main.c b/exam2/ex2/main.c
new file mode 100644
index 0000000..45422d4
--- /dev/null
+++ b/exam2/ex2/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _element {
+  char c;
+  struct _element *next;
+} element;
+
+int main(int argc, char **argv) {
+
+  // read user input
+  char str[16];
+  scanf("%s", str);
+  int len = strlen(str);
+  // cli args
+  if (argc == 1) {
+    printf("need more arguments");
+    return EXIT_FAILURE;
+  }
+
+  for (int i = 0; i < argc; i++) {
+    if (!strcmp(argv[i], "-c")) {
+      // do stuff with atof/atoi (argv[++i])
+    }
+  }
+
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/exam2/ex3/Makefile b/exam2/ex3/Makefile
new file mode 100644
index 0000000..478f28e
--- /dev/null
+++ b/exam2/ex3/Makefile
@@ -0,0 +1,10 @@
+main: main.o
+	gcc -o $@ $< -fsanitize=address -fsanitize=leak
+
+main.o: main.c 
+	gcc -c -Wall -Wextra -pedantic -fsanitize=address -fsanitize=leak $<
+
+clean:
+	rm -f *.o main
+
+rebuild: clean main
\ No newline at end of file
diff --git a/exam2/ex3/main.c b/exam2/ex3/main.c
new file mode 100644
index 0000000..45422d4
--- /dev/null
+++ b/exam2/ex3/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _element {
+  char c;
+  struct _element *next;
+} element;
+
+int main(int argc, char **argv) {
+
+  // read user input
+  char str[16];
+  scanf("%s", str);
+  int len = strlen(str);
+  // cli args
+  if (argc == 1) {
+    printf("need more arguments");
+    return EXIT_FAILURE;
+  }
+
+  for (int i = 0; i < argc; i++) {
+    if (!strcmp(argv[i], "-c")) {
+      // do stuff with atof/atoi (argv[++i])
+    }
+  }
+
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/exam2/ex4/Makefile b/exam2/ex4/Makefile
new file mode 100644
index 0000000..478f28e
--- /dev/null
+++ b/exam2/ex4/Makefile
@@ -0,0 +1,10 @@
+main: main.o
+	gcc -o $@ $< -fsanitize=address -fsanitize=leak
+
+main.o: main.c 
+	gcc -c -Wall -Wextra -pedantic -fsanitize=address -fsanitize=leak $<
+
+clean:
+	rm -f *.o main
+
+rebuild: clean main
\ No newline at end of file
diff --git a/exam2/ex4/main.c b/exam2/ex4/main.c
new file mode 100644
index 0000000..45422d4
--- /dev/null
+++ b/exam2/ex4/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _element {
+  char c;
+  struct _element *next;
+} element;
+
+int main(int argc, char **argv) {
+
+  // read user input
+  char str[16];
+  scanf("%s", str);
+  int len = strlen(str);
+  // cli args
+  if (argc == 1) {
+    printf("need more arguments");
+    return EXIT_FAILURE;
+  }
+
+  for (int i = 0; i < argc; i++) {
+    if (!strcmp(argv[i], "-c")) {
+      // do stuff with atof/atoi (argv[++i])
+    }
+  }
+
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/exam2/ex5/Makefile b/exam2/ex5/Makefile
new file mode 100644
index 0000000..478f28e
--- /dev/null
+++ b/exam2/ex5/Makefile
@@ -0,0 +1,10 @@
+main: main.o
+	gcc -o $@ $< -fsanitize=address -fsanitize=leak
+
+main.o: main.c 
+	gcc -c -Wall -Wextra -pedantic -fsanitize=address -fsanitize=leak $<
+
+clean:
+	rm -f *.o main
+
+rebuild: clean main
\ No newline at end of file
diff --git a/exam2/ex5/main.c b/exam2/ex5/main.c
new file mode 100644
index 0000000..45422d4
--- /dev/null
+++ b/exam2/ex5/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _element {
+  char c;
+  struct _element *next;
+} element;
+
+int main(int argc, char **argv) {
+
+  // read user input
+  char str[16];
+  scanf("%s", str);
+  int len = strlen(str);
+  // cli args
+  if (argc == 1) {
+    printf("need more arguments");
+    return EXIT_FAILURE;
+  }
+
+  for (int i = 0; i < argc; i++) {
+    if (!strcmp(argv[i], "-c")) {
+      // do stuff with atof/atoi (argv[++i])
+    }
+  }
+
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
-- 
GitLab