void *

Started by
0 comments, last by HappyDude 22 years, 6 months ago
I''m just wondering, what does it mean when you declare a variable a void *. I use it when I want to pass a multi-dimensional array to a function, and it''s used in fread/fwrite, but I want to know what exactly void * means...
Advertisement
Well, it means that the region of memory pointed to doesn''t have any particular type. That is, you need to tell the compiler what is represented by the binary data by using a typecast.
void* memoryWithNoType = malloc(100);
char* p = (char*)memoryWithNoType;
This tells the compiler that when using the pointer p, the memory space in *memoryWithNoType should be interpreted as single byte ascii characters.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

This topic is closed to new replies.

Advertisement