N
nick048
Hi to all
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 *'
Can someone help me ? I am a newby in C++.
Thank You
Nino
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 *'
Can someone help me ? I am a newby in C++.
Thank You
Nino