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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #ifndef STRING__H
#define STRING__H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef char* String;
void create(String *s, const char src[]);
/* Initialiser à partir d'une chaîne de caractères classique */
void destroy(String *str);
/* Détruire */
size_t length(String str);
/* Obtenir le nombre de caractères de la chaîne */
char get(String str, unsigned int i);
/* Obtenir le ième caractère de la chaîne */
void replace(String *str, unsigned int i, char cara);
/* Remplacer le ième caractère de la chaîne par un nouveau caractère */
bool add(String *str, char c);
/* Ajouter un nouveau caractère à la fin de la chaîne */
void append(String *str, const char src[]);
/* Ajouter une chaîne de caractères à la fin d'une String */
void insert(String *str, unsigned int i, char c);
/* Ajoute un nouveau caractère en position i de la chaîne. La longueur de la
* chaîne est donc augmentée de 1.
* Pré-condition: 0<=i<=length */
void delete(String *str, unsigned int i);
/* Supprimer le caractère à la position i */
String substring(String str, unsigned int i_debut, unsigned int i_fin);
/* Retourne une nouvelle String initialisée avec la partie de la chaîne comprise
* entre les indices début et fin, début inclu et fin exclu */
#endif |
Partager