Modifier valeur d'un char **
Résolu/Fermé
Nerethim
Messages postés
2
Date d'inscription
jeudi 11 février 2016
Statut
Membre
Dernière intervention
12 février 2016
-
11 févr. 2016 à 23:15
fiddy Messages postés 11069 Date d'inscription samedi 5 mai 2007 Statut Contributeur Dernière intervention 23 avril 2022 - 12 févr. 2016 à 10:31
fiddy Messages postés 11069 Date d'inscription samedi 5 mai 2007 Statut Contributeur Dernière intervention 23 avril 2022 - 12 févr. 2016 à 10:31
A voir également:
- Char**
- Char ai - Guide
- Convertir string en char ✓ - Forum C++
- Char code ascii - Guide
- Convertir char en int java - Forum Programmation
- Convertir int en char c - Forum C
1 réponse
Dalfab
Messages postés
706
Date d'inscription
dimanche 7 février 2016
Statut
Membre
Dernière intervention
2 novembre 2023
101
11 févr. 2016 à 23:43
11 févr. 2016 à 23:43
Bonjour,
Tu veux créer un tableau de tableaux.
Il faut allouer le tableau, mais aussi chacune des lignes!
Tu veux créer un tableau de tableaux.
Il faut allouer le tableau, mais aussi chacune des lignes!
int main() { char **map; map = malloc(sizeof(char *) *2); for ( int i = 0 ; i < 2 ; ++i ) { map[i] = malloc( sizeof(char) * 4 ); // pour 3 caracteres + 1 terminateur } strcpy( map[0] , "abc" ); strcpy( map[1] , "def" ); map[0][1] = 'x'; }
12 févr. 2016 à 09:53
12 févr. 2016 à 10:31