arwenita
Messages postés5Date d'inscriptiondimanche 26 octobre 2003StatutMembreDernière intervention27 novembre 2004
-
11 juin 2004 à 21:47
cs_djl
Messages postés3011Date d'inscriptionjeudi 26 septembre 2002StatutMembreDernière intervention27 novembre 2004
-
12 juin 2004 à 11:18
Encore un petit problème en C++...
Dans mon programme, je voudrais afficher une liste de nombres (premiers), que je récupère de la fonction Crible(n).
Le seul problème, ce que je n'arrive a afficher que des barres à la place de nombres. Il faudrait que je convertise les entiers i en char*, ca que je ne sais pas faire.
bool* Liste = new bool[n+1];
char* Affich;
int j=0;
Liste = Crible(n);
for(int i=0; i<n+1;i++)
{
if(Liste[i]==true)
{
Affich[j]=i;
j++;
Affich[j]=' ';
j++;
}
}
MemoGene->Lines->Add(Affich);
delete Liste;
Si quelqu'un sait faire cette conversion ou s'il a une autre idée, il serait le bienvenu !
Merci d'avance !
ymca2003
Messages postés2070Date d'inscriptionmardi 22 avril 2003StatutMembreDernière intervention 3 juillet 20067 11 juin 2004 à 23:13
#include <stdlib.h>
char *itoa(int value, char *string, int radix);
Description
Converts an integer to a string.
itoa converts value to a null-terminated string and stores the result in string. With itoa, value is an integer.
radix specifies the base to be used in converting value; it must be between 2 and 36, inclusive. If value is negative and radix is 10, the first character of string is the minus sign (-).
Note: The space allocated for string must be large enough to hold the returned string, including the terminating null character (\0). itoa can return up to 17 bytes.