In C++, this is a required syntax to tell the compiler that you want to convert the result from malloc, which is (void *) into (int *). In C, we normally write it like this
Code:
int *ptr_one = malloc(sizeof(int));
;
The compiler will automatically convert the right-hand side (void*) to the type of the left-hand side (int*). The type (int*) means pointer to int. The type (void*) basically means pointer to "something", where "something" is to be determined by the programmer.
EDIT: you will also see the above line written this way
Code:
int *ptr = malloc(n * sizeof(*ptr));
This will allocate n items, each of the appropriate size (for example, int). This way if you later change the type, you need only change one word, example to allocate n doubles:
Code:
double *ptr = malloc(n * sizeof(*ptr));