I want to ask user enter an integer to create a 2D array like this:
void* myArray_1[2][userInput];
which is not allowed by compiler because the userInput
is not constant.
Then I tried this:
void** myArray_2 = new void*[rowCount];
for(int i = 0; i < rowCount; ++i)
myArray_2[i] = new void[colCount];
which causes the below error:
Error: array of void is NOT allowed.
How can I create an array of void whose size will be specified by the user input from command line?
Edit:
my function prototype is:
errorType EventGet ( EVENT_HANDLE hEvent, void * pBuffer);
I used this:
void* myArray_3[2][10];
...
myArray_3[0][count++] = myOtherArray[0]; //myOtherArray[0] contains a handle and myOtherArray is an 1D array with size of 2.
EventGet ( myEventHandle, myArray_3[0][i]);
and I got correct result. Now the only thing I want is to allow the user to specify the second dimension size instead of 10.