Mensaje
 
a
Todos
General information
Foro:
Visual C++
Category:
Programación, sintaxis y comandos
Título:
Error on Array passed in a Function
Miscellaneous
ID de la conversación:
01171399
ID del mensaje:
01171399
Views:
53
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
Responder
Mapa
Ver