Why you can't dereference a void* pointer

Why you can’t dereference a void* pointer

Why you can't dereference avoid pointer

The compiler will not let you dereference avoid pointer because it does not know the size of the object pointed to. If the pointer points to a char, which is one byte, the compiler needs to access only that one byte; if the
pointer points to a double, not only is there more memory that needs to be accessed, but the layout is very different since it is represented as a floating point number.

You can of course use avoid, and it's very handy for writing generic code in C without templates, but you need to typecast your pointer to the right type before you dereference it.

So, Why you can't dereference avoid pointer …. You know it now.

Feel free to ask something or to comment.

  • Article By :
    Shayaan Ahmad Noori, a highly accomplished and renowned Communication expert. He is currently Founder and C.E.O of Creative Buffs. He has extensive work experience of 14+ years, out of which he carries a wide range of experience of 9 years with Tech Mahindra, Smile Foundation, CanvasM Technology Private Limited, Australian Training and Management College and much more. He has done M.B.A and P.G.D.B.M in Marketing and HR and also has done Masters in Sociology. He has done approx more than 100 training sessions in Communication Skills, Marketing, Management, Society and development and Digital Marketing.

Random Posts

Leave a Reply