Skip to content
Snippets Groups Projects
Commit 9b862bf3 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

fin chaines de caracteres

parent 48f6267f
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@
# Chaînes de caractères (strings)
- Chaîne de caractère `==` tableaude caractères **terminé par la valeur** `'\0'`{.C} ou `0`{.C}.
- Chaîne de caractère `==` tableau de caractères **terminé par la valeur** `'\0'`{.C} ou `0`{.C}.
## Exemple
......@@ -31,6 +31,36 @@ char str = "HELLO !";
Est représenté par
| `H` | `E` | `L` | `L` | `O` | ` ` | `!` | `\0`|
| `H` | `E` | `L` | `L` | `O` | | `!` | `\0`|
|------|------|------|------|------|------|------|-----|
| `72` | `69` | `76` | `76` | `79` | `32` | `33` | `0` |
# Syntaxe
```C
char name[5];
name[0] = 'P'; // = 70;
name[1] = 'a'; // = 97;
name[2] = 'u'; // = 117;
name[3] = 'l'; // = 108;
name[4] = '\0'; // = 0;
char name[] = {'P', 'a', 'u', 'l', '\0'};
char name[5] = "Paul";
char name[] = "Paul";
char name[100] = "Paul is not 100 characters long.";
```
# Fonctions
- Il existe une grande quantités de fonction pour la manipulation de chaînes de caractères dans `string.h`.
- Fonctions principales:
```C
size_t strlen(char *str);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t len);
int strncmp(char *str1, char *str2, size_t len);
int strcmp(char *str1, char *str2);
```
- Pour avoir la liste complète: `man string.h`.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment