Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error on Array passed in a Function
Message
 
À
Tous
Information générale
Forum:
Visual C++
Catégorie:
Codage, syntaxe et commandes
Titre:
Error on Array passed in a Function
Divers
Thread ID:
01171399
Message ID:
01171399
Vues:
51
Hi to all
I am a newby in C++.
I have in my program 2 arrays DIM 2:
firstArray[5] and secondArray[5]
fisrtArray is for example 'ABCD' plus terminator '\0'.

I need to create a function in order to perform this in my program:

secondArray = createArray(firstArray); ********

I have. with my poor experience, create a function like this:
char *createArray(char *originalArray) 
{ 
    char *tmpArray; 
    // Allocation 
    tmpArray = new char[ADIM];  // ADIM is definied as 5 
    //for(int i=0; i<ADIM; i++) 
      tmpArray = new char[ADIM]; 
   // original must be the fistArray 
        tmpArray[0] = originalArray[2]; 
        tmpArray[1] = originalArray[0]; 
        tmpArray[2] = originalArray[3]; 
        tmpArray[3] = originalArray[1]; 
                tmpArray[4] = '\0'; 
return tmpArray; 
}
But this function don't run and I have fron VS C++ the errors:
error C2440: '=': impossible to converte from 'char' to 'char *'
This error occur in the line marked with ********

Can someone help me ? I am a newby in C++.

Thank You
Nino
Répondre
Fil
Voir

Click here to load this message in the networking platform