Programmation bas niveau (BNV) Help

Correction : Les tableaux

Correction Exercice 1

Objectif : créer une fonction qui calcule la longueur d'une chaine de caractères et la retourne

int str_len(char *str) { int i; int len; i = 0; len = 0; while(str[i] != '\0') { i++; len++; } return(len); }

Correction Exercice 2

Objectif : créer une fonction qui compare deux chaines de caractères et retourne 1 si elles sont identiques, 0 sinon

int str_cmp(char *str1, char *str2) { int i; i = 0; while(str1[i] != '\0') { if(str1[i] != str2[i]) { return(0); } i++; } if(str1[i] == str2[i]) { return(1); } return(0); }

Correction Exercice 3

Objectif : créer une fonction qui affiche une chaine de caractères à l'envers.

void str_rev(char *str) { int i; i = str_len(str); while(i >= 0) { printf("%c", str[i]); i--; } }
23 September 2025