Maybe the following example will clarify by breaking down your code into two separate statements -
#include <stdio.h>
int main()
{
float a = 2.5;
int b;
b = (int)a; // Why asterisk is not used with "int"?
void* ab_ptr = &b;
printf("Value of 'a' is %d\n", *(int*)ab_ptr); // Why two times asterisk is used here?
// Use multiple statements for illustration
int *iptr = (int*)ab_ptr; // cast void pointer to pointer to an int
int x = *iptr; // dereference int pointer
printf("Value of 'a' is %d\n", x);
}
Perhaps using additional parenthesis would also clarify the meaning of the printf statemet -
printf("Value of 'a' is %d\n", *((int*)ab_ptr)); // Why two times asterisk is used here?
b = (int) a; // Why asterisk is not used with "int"?
No asterisk is needed because casting a variable from one type to another is not a dereferencing operation. There are no pointers involved here.