O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Type Casts

You now know enough about dynamic memory to reserve blocks of it, but what you actually want to do is to store and retrieve data in these blocks.

The void pointer variable introduced in the previous section allows you to store and retrieve any kind of address, but it specifically does not allow you to read or write any data through it using the dereferencing operator (*) as you learned how to do in Chapter 9. The reason for this is that the void pointer variable lacks data type information. Since a void pointer can point to anything, the system cannot know if it should read or write a 1-byte char or a 4-byte integer, or something completely different.

What the system needs in such a situation is a hint from you, the programmer. You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required