0
Malloc
What the following code does? X=(int*)Malloc(sizeof(int)) * 6; In c programming language...
4 Respostas
+ 11
Syed Waseem
When allocating memory dynamically in the heap malloc function is used, the function malloc retuns a handle which needs to be stored in a pointer to appropiate datatype
where X is an integer pointer you can do like this way too
int* ptr = (int*) malloc(sizeof(int) * 6);
X = (int*) malloc(6 * sizeof(int));
// 6 ints. Memory is allocated at the heap (a total of 24 bytes, assuming sizeof(int) is 4 bytes
when your task is completed then free the memory from being safe with memory leakage.
free(X)
+ 10
Yes 6 integers with memory allocation of 24 bytes as pointer has defined data type as integer
+ 1
Thanks,
For Your help...🤝
0
So, it returns total 6 int pointer to x...