aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine5/29_filtre.c
blob: 37a5625beba2decb43804985daf99747e32feb3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
}