lots of viewers but no replies :/
anywho, here is another problem I had as well
Quote
The variables arr1 and arr2 have been declared as pointers to integers. An array of 10 elements has been allocated, its pointer assigned to arr1, and the elements initialized to some values. Allocate an array of 20 elements, assign its pointer to arr2, copy the 10 elements from arr1 to the first 10 elements of arr2, and initialize the remainder of the elements of arr2 to 0.
my code:
Code
for (int i = 0; i<20;i++) {
if (i <10) {
arr2[i] = new int;
arr2[i] = arr1[i]; }
else arr2[i] = new int(0);
}
I keep getting this error:
Code
CTest.cpp: In function ‘int main()’:
CTest.cpp:5:16: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
CTest.cpp:7:26: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
Line 5 is the if statement. I don't understand what is the problem. My prof didn't really explain this stuff very well to us. I don't quite understand how you can copy the contents of arr1 into arr2 without getting that error.