Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
--- /dev/null
+TARGET = exo1
+LIBS =
+CC = gcc
+# Enforce C11 ISO standard for now
+CFLAGS = -std=c11 -g -Wall
+LDFLAGS = -g -Wall
+
+.PHONY: default all clean
+
+default: $(TARGET)
+all: default
+
+OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
+HEADERS = $(wildcard *.h)
+
+%.o: %.c $(HEADERS)
+ $(CC) $(CFLAGS) -c $< -o $@
+
+.PRECIOUS: $(TARGET) $(OBJECTS)
+
+$(TARGET): $(OBJECTS)
+ $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
+
+clean:
+ -rm -f $(TARGET) $(OBJECTS)
+
+disassemble: $(TARGET)
+ objdump -d $< | less
+
+symbols: $(TARGET)
+ objdump -t $< | sort | less
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+
+int promptValue() {
+ int value;
+ scanf("%d", &value);
+ return value;
+}
+
+int main() {
+ int* arr;
+ printf("Longeur?\n");
+ int size = promptValue();
+ arr = malloc(sizeof(arr[size]));
+
+ for (int i = 0; i < size; i++) {
+ printf("Valeur?\n");
+ arr[i] = promptValue();
+ }
+
+ printf("Sortie\n");
+ int sum = 0;
+ for (int i = 0; i < size; i++) {
+ printf("%d (%d)\n", arr[i], sum += arr[i]);
+ }
+
+ free(arr);
+
+ return 0;
+}