copy integer array into string array

Stack.cpp: In copy constructor ‘Stack::Stack(const Stack&)’:
Stack.cpp:48: error: cannot convert ‘int*’ to ‘char*’ for argument ‘1’ to ‘char* strcpy(char*, const char*)’
Stack.cpp: In member function ‘Stack& Stack::operator=(const Stack&)’:
Stack.cpp:67: error: cannot convert ‘int*’ to ‘char*’ for argument ‘1’ to ‘char* strcpy(char*, const char*)’
Stack.cpp: In member function ‘void Stack::push(int)’:
Stack.cpp:167: error: cannot convert ‘int*’ to ‘char*’ for argument ‘1’ to ‘char* strcpy(char*, const char*)’
Stack.cpp:169: error: cannot convert ‘int**’ to ‘int*’ in assignment
Stack.cpp: In member function ‘void Stack::pop() const’:
Stack.cpp:189: error: decrement of data-member ‘Stack::stacksize’ in read-only structure

Stack::Stack(const Stack& s)
{
        stacksize = s.stacksize;
        stackcapacity = s.stackcapacity;
        stackarray = new int [stackcapacity];
        strcpy(stackarray, s.stackarray);
}

Stack& Stack::operator=(const Stack& rightOp)
{
        if(this == &rightOp)
                {
                        return *this;
                }
                delete[] stackarray;
                stacksize = rightOp.stacksize;
                stackcapacity = rightOp.stackcapacity;
                stackarray = new int [stackcapacity];
strcpy(stackarray, rightOp.stackarray);
return *this;
}

void Stack::push(int)
{
if (stacksize = stackcapacity)
{
stackcapacity = stacksize * 2;
int* p;
p = new int[stackcapacity];
strcpy(stackarray, p);
delete stackarray;
stackarray = &p;
}

}

i want to know how do i copy the values of the stack array into s.stackarray.
I think I can do it with a for loop but i dont know how..can anyone help
strcpy() doesn't work with any array - only char arrays (C-style strings) - due to the nature of how it works. Like you say, you'll need to iterate over the arrays and swap each element individually. How much do you know about using for loops?
im not to familiar with for loops .. thats what i was looking for help on and how to swap back and forth .. if you could help that would be great
after Zhuge:
1
2
3
4
a[]={1,2,3,4,5,6,7,8,9};
b[10]={0};
for(int i=0;i<10;i++)
b[i]=a[i];

//the tenth element is NUL or '\0' and is added 'automatically' but the size of the array must allow for this!
Topic archived. No new replies allowed.