Given that the sizes of pointers to different data types(built-in or
structures) can be different, though malloc returns a void *, it is
assigned to any pointer type. The language allows it. From this, can I
conclude that the size of (void *) should be the maximum ?
If this is not the case, consider the following scenario.
Suppose there is a type T (built-in or structure) whose pointer size
is bigger than the sizeof (void *) ie sizeof (T *) sizeof(void *).
Consider;
T *var;
var = malloc(sizeof(T ));
Then how can the pointer returned by malloc(which would be a void *)
for the sizeof type T be assigned to a variabe of type T.
Thanks
structures) can be different, though malloc returns a void *, it is
assigned to any pointer type. The language allows it. From this, can I
conclude that the size of (void *) should be the maximum ?
If this is not the case, consider the following scenario.
Suppose there is a type T (built-in or structure) whose pointer size
is bigger than the sizeof (void *) ie sizeof (T *) sizeof(void *).
Consider;
T *var;
var = malloc(sizeof(T ));
Then how can the pointer returned by malloc(which would be a void *)
for the sizeof type T be assigned to a variabe of type T.
Thanks
Comment