Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error on Array passed in a Function
Message
 
To
All
General information
Forum:
Visual C++
Category:
Coding, syntax & commands
Title:
Error on Array passed in a Function
Miscellaneous
Thread ID:
01171399
Message ID:
01171399
Views:
50
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
Reply
Map
View

Click here to load this message in the networking platform