--- /dev/null
+TARGET = exo3
+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>
+
+//FIXME: Comment the code !!!
+
+void swap(char* v1, char* v2) {
+ if (v1 != v2) {
+ char tmp = *v1;
+ *v1 = *v2;
+ *v2 = tmp;
+ }
+}
+
+int stringLength(const char* str) {
+ int length;
+
+ for(length = 0; str[length] != '\0'; ++length);
+ return length;
+}
+
+// FIXME: this function have issues with non english characters
+void reverseString(char* str) {
+ int length = stringLength(str);
+
+ for (int i = length - 1; i >= length/2; --i) {
+ swap(&str[i], &str[(length - 1) - i]);
+ }
+}
+
+int main() {
+ char msg[] = "Bonjour et a bientot";
+ int length = stringLength(msg);
+
+ printf("La chaine de caracteres est \"%s\" et a pour longueur %d caractere(s)\n", msg, length);
+ reverseString(msg);
+ printf("La chaine inversee de caracteres est \"%s\"\n", msg);
+
+ return 0;
+}