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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!