aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine5/29_filtre.c
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-03-10 10:31:33 +0100
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-03-10 10:31:33 +0100
commit4a3afaf44aa29e66a6c879c60322015a2920a5ab (patch)
tree64d3e7748078b4215341aeead3b30eaaf28070ad /semestre 2/informatique/tme/semaine5/29_filtre.c
parent77bfb2ccd3152c1f41d43dc192ba86ca8fd0f72f (diff)
Ajout de la semaine des cours du 3 au 7 mars
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;
+}