A voir également:
- Comment initialisé un char*
- Coco char - Accueil - Réseaux sociaux
- Char(10) excel francais ✓ - Forum Excel
- If char ✓ - Forum Programmation
- Char ** - Forum C
- Disque dur non initialisé - Forum Périphériques
1 réponse
Bonjour,
Avec malloc ou calloc : http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man3/malloc.3.html
Voici un exemple :
Cdlt
Avec malloc ou calloc : http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man3/malloc.3.html
Voici un exemple :
char *p=NULL;
p=malloc(10); //allocation de 10 char (\0 compris).
if(p==NULL) { //on vérifie que l'allocation s'est bien déroulée
fputs("erreur allocation\n",stderr);
exit(1);
}
//instruction avec malloc
free(p),p=NULL; //désallocation lorsque p ne sera plus utilisé.
Cdlt