int** returnColumnSizes = (int**)malloc(sizeof(int*) * 100); is this correct
时间: 2023-09-30 14:05:46 浏览: 100
As an AI language model, I cannot determine whether this code is correct without more context. However, assuming that the code is attempting to allocate memory for an array of 100 int pointers, then the syntax is correct. The code allocates memory using the malloc function and casts the returned pointer to an int double pointer. The size of the memory allocated is determined by multiplying the size of a single int pointer by the number of desired elements, which is 100 in this case.
相关问题
int** returnColumnSizes = (int*)malloc(sizeof(int*) * 100); is this correct
No, it is not correct.
The correct way to allocate memory for an array of integers is:
```
int* returnColumnSizes = (int*)malloc(sizeof(int) * 100);
```
This allocates memory for an array of 100 integers, and the pointer `returnColumnSizes` points to the first element of the array.
int** returnColumnSizes = (int**)malloc(sizeof(int) * 2000); what is the problem
The problem is that the allocated memory size is not correct. It should be sizeof(int*) * 2000 instead of sizeof(int) * 2000. This is because we are allocating memory for an array of pointers to integers, not for an array of integers.
阅读全文