#include int calculerNombreCaracteres(const char* chaine) { int cpt = 0; while (chaine[cpt] != 0x00) { cpt++; } return cpt; } void copier(const char* src, char* dst) { int i = 0; while (src[i] != 0x00) { dst[i] = src[i]; i++; } dst[i] = 0x00; } void substituer(char* chaine, char ancien, char nouveau) { int i = 0; while (chaine[i] != 0x00) { if (chaine[i] == ancien) { chaine[i] = nouveau; } i++; } } void copier2(const char* src, char* dst) { char* s = (char*)src; char* d = dst; while (*s != 0x00) { *d = *s; s++; d++; } *d = 0x00; } void substituer2(char* chaine, char ancien, char nouveau) { char* c = chaine; while (*c != 0x00) { if (*c == ancien) { c[0] = nouveau; } c++; } } void main(void) { char* s = "abcdefabcdef"; // Attention! non modifiable char t[20]; printf("Chaine : %s\n", s); printf("Longeur : %d\n", calculerNombreCaracteres(s)); copier(s, t); printf("Chaine copiee : %s\n", s); printf("%s\n", t); substituer(t, 'a', 'f'); printf("Substituion de 'a' par 'f' : %s\n", t); substituer(t, 'f', '0'); printf("Substituion de 'f' par '0' : %s\n", t); }