aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine5/29_filtre.c
diff options
context:
space:
mode:
Diffstat (limited to 'semestre 2/informatique/tme/semaine5/29_filtre.c')
-rw-r--r--semestre 2/informatique/tme/semaine5/29_filtre.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/semestre 2/informatique/tme/semaine5/29_filtre.c b/semestre 2/informatique/tme/semaine5/29_filtre.c
new file mode 100644
index 0000000..37a5625
--- /dev/null
+++ b/semestre 2/informatique/tme/semaine5/29_filtre.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+void show_filtre(char *s){
+ for (int i = 0; s[i] != '\0'; i++) {
+ if (s[i] >= 'A' && s[i] <= 'z') printf("%c", s[i]);
+ }
+}
+
+char *filtre(char *s) {
+ char *ns = malloc(sizeof(char) * strlen(s));
+ int j = 0;
+ for (int i = 0; s[i] != '\0'; i++){
+ if (s[i] >= 'A' && s[i] <= 'z') ns[j++] = s[i];
+ }
+ return ns;
+}
+
+int main() {
+ char *s = "Hello World! What's up guys?";
+ show_filtre(s);
+ printf("\n%s\n", filtre(s));
+ return 0;
+}