2025-03-17 12:53:05 +00:00

40 lines
1.0 KiB
C

#include <stdio.h>
#include <stdlib.h>
int main()
{
// Partie A: Implémentation des fonctions de base
printf("Partie A: Fonctions de base sur les chaînes\n");
char chaine1[50] = "Bonjour";
char chaine2[50] = "Monde";
char chaine3[100];
printf("Chaine1: \"%s\"\n", chaine1);
printf("Chaine2: \"%s\"\n", chaine2);
printf("Longueur de chaine1: %d caractères\n", ma_strlen(chaine1));
ma_strcpy(chaine3, chaine1);
printf("Copie de chaine1 dans chaine3: \"%s\"\n", chaine3);
ma_strcat(chaine3, " ");
ma_strcat(chaine3, chaine2);
printf("Concaténation: \"%s\"\n\n", chaine3);
// Partie B: Allocation dynamique
printf("Partie B: Allocation dynamique\n");
char *inverse = inverser_chaine(chaine3);
printf("Chaîne inversée: \"%s\"\n", inverse);
char *voyelles = filtrer_voyelles(chaine3);
printf("Voyelles uniquement: \"%s\"\n", voyelles);
// Libération de la mémoire
free(inverse);
free(voyelles);
return 0;
}