Question: C++ Allocate an array of 100 integer pointers and assign the resulting pointer to the appropriately declared variable, ip_arr. Allocate 100 integers and assign the
C++
Allocate an array of 100 integer pointers and assign the resulting pointer to the appropriately declared variable, ip_arr. Allocate 100 integers and assign the resulting pointers to the elements of ip_arr. Initialize each integer value to -1.
this is what i have but it generates an error:
int *ip_arr = new int [100]; for(int i = 0; i < 100; i++) { *ip_arr[i] = new int(-1); }
here is the error:
CTest.cpp:5:11: error: invalid type argument of unary * (have int) *ip_arr[i] = new int(-1); ^
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
