probl�me allocation dynamique dans C++
bonsoir les amis,
je veux faire une allocation dynamique d'une variable de type chaine de caract�re mais j'ai eu beaucoup de probl�mes lors de la compilation du programme.
voici mon programme:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int main(){
...
tab[0]="";
string sequence[nb_seq];
string seq;
char *buffer2;
buffer2=new char;
strncpy(buffer2,seq,k);
u++;
lamda=0;verif=0;
while((lamda<u) && (verif<1)){
X=strcmp(tab[lamda],buffer2);
if(X==0){
verif++;
}
lamda++;
}
if (verif==0){
tab[u]=buffer2;
}
else u--;
... |
error: cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '2' to 'char* strncpy(char*, const char*, size_t)'|
je pense que c'est un probl�me lors de la d�claration du buffer2 .
merci pour votre aide