Problème tout bête

cs_Raoul12 Messages postés 15 Date d'inscription vendredi 1 mars 2002 Statut Membre Dernière intervention 3 novembre 2003 - 30 août 2002 à 09:54
cs_Raoul12 Messages postés 15 Date d'inscription vendredi 1 mars 2002 Statut Membre Dernière intervention 3 novembre 2003 - 30 août 2002 à 19:33
voilà, je débute dans le c++ et je voudrais faire ça:

char hohun[32] ;
hohun = "hohun" ;

mais ça ne marche pas... pourtant si je fais ça:

char hohun[32] = "hohun" ;

là ça marche... aidez-moi!!!

5 réponses

DeAtHCrAsH Messages postés 2670 Date d'inscription vendredi 25 janvier 2002 Statut Membre Dernière intervention 6 février 2013
30 août 2002 à 15:33
Essaye plutot ca:

char *hohun;
hohun = "hohun";
0
jfloviou Messages postés 17 Date d'inscription samedi 23 mars 2002 Statut Membre Dernière intervention 25 septembre 2002
30 août 2002 à 19:21
jaja
0
jfloviou Messages postés 17 Date d'inscription samedi 23 mars 2002 Statut Membre Dernière intervention 25 septembre 2002
30 août 2002 à 19:25
pardon...

attention,
char * hohun;
n'initialise pas le buffer !!! donc tu ne sais pas ou se trouve le reste de ta chaine ensuite... (il y a peu de chance que ca pose probleme pour une petite chaine, mais par reflexe il faut mieux:

char * hohun;
hohun=(char *) malloc(sizeof("blalblabl"));
strcpy(hohun,"blalblabl");

ou:

char hohun[100]; // ou 10(ne pas oublier de conpter '\0')
strcpy(hohun,"blalblabl");

a+

jaja
0
cs_Raoul12 Messages postés 15 Date d'inscription vendredi 1 mars 2002 Statut Membre Dernière intervention 3 novembre 2003
30 août 2002 à 19:31
oui mais ce n'est pas ce qu'il me faut, il me faut un tableau...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Raoul12 Messages postés 15 Date d'inscription vendredi 1 mars 2002 Statut Membre Dernière intervention 3 novembre 2003
30 août 2002 à 19:33
ça marche, merci
0
Rejoignez-nous