/* // test_lib_string.c // // // Created by Valentin Emiya on 03/02/12. // Copyright (c) 2012 LIF. All rights reserved. */ #include #include "lib_string.h" #define N 26 int main(void){ char *t[N]; int n=0; char *s1, *s2; char s[] = "les pointeurs"; /* test de string_length */ printf("%s (%d caractères)\n", s, string_length(s)); /* test de string_length */ /* ENLEVEZ CES COMMENTAIRES LORSQUE VOUS AVEZ ECRIT LA FONCTION string_flip(s); printf("Miroir: %s\n", s); */ t[n++]="Ramadane"; t[n++]="Meriem"; t[n++]="Charly"; t[n++]="Mamadou"; t[n++]="Thomas"; t[n++]="Stephane"; t[n++]="Aboubacar Sidy"; t[n++]="Mustapha"; t[n++]="Guillaume"; t[n++]="Mohammed Lamine"; t[n++]="Brice"; t[n++]="Hadrien"; t[n++]="Clara"; t[n++]="Laurent"; t[n++]="Johnny"; t[n++]="Niass"; t[n++]="Julien"; t[n++]="Yoan"; t[n++]="Thi Truong Khai"; t[n++]="Dai Hung"; t[n++]="Tahina Ariela"; t[n++]="Lalaina"; t[n++]="Maximilien Serge"; t[n++]="Oleg"; t[n++]="Nicolas"; t[n++]="Valentin"; /* Remarque: dans le code ci-dessus, chaque case t[n] est un pointeur vers un char (char *), auquel on assigne l'adresse d'une chaine de caractère constante. On ne peut pas modifier cette constante: mirroir(t[n]) n'est pas valide alors que miroir(s) est valide. Cf. p.67 du poly pour plus d'information */ /* test de string_length */ for (n=0; n %s : %d\n", s1, s2, string_cmp(s1,s2)); s1 = *(t+2); s2 = *(t+3); printf("%s <> %s : %d\n", s1, s2, string_cmp(s1,s2)); s1 = *(t+4); s2 = *(t+4); printf("%s <> %s : %d\n", s1, s2, string_cmp(s1,s2)); */ /* test de print_tableau_strings */ /* ENLEVEZ CES COMMENTAIRES LORSQUE VOUS AVEZ ECRIT LA FONCTION print_tableau_strings(t, N); */ /* test de tri_tableau_strings */ /* ENLEVEZ CES COMMENTAIRES LORSQUE VOUS AVEZ ECRIT LA FONCTION printf("\nTri par ordre lexicographique\n"); tri_tableau_strings(t, N); print_tableau_strings(t, N); */ /* test de stringlength_cmp */ /* ENLEVEZ CES COMMENTAIRES LORSQUE VOUS AVEZ ECRIT LA FONCTION s1 = *(t); s2 = *(t+1); printf("%s <> %s : %d\n", s1, s2, stringlength_cmp(s1,s2)); s1 = *(t+2); s2 = *(t+3); printf("%s <> %s : %d\n", s1, s2, stringlength_cmp(s1,s2)); s1 = *(t+4); s2 = *(t+4); printf("%s <> %s : %d\n", s1, s2, stringlength_cmp(s1,s2)); */ /* test de tri_tableau_strings_bylength */ /* ENLEVEZ CES COMMENTAIRES LORSQUE VOUS AVEZ ECRIT LA FONCTION printf("\nTri par longueur\n"); tri_tableau_strings_bylength(t, N); print_tableau_strings(t, N); */ return 0; }