Hi. I've recently seen the use of "void *" in functions and i'm trying to figure out how it all works. If a function accepts 'void *' as a parameter that means i can pass in a pointer to anything i want, right? Like:
void Func(void * ThisPtr)
{
//do something with ThisPtr
}
int Num = 1;
char Array[10];
struct AStruct
{
int a, b, c;
}
Func(&Num);
Func(&Array);
Func(&AStruct);
My compiler accepts that but i want to understand how it works. How can i determine the scope of what the ThisPtr points to? Like if i wanted to use fwrite of something in the Func(void *) function, how could i get the size of what i passed in (besides passing it in as another parameter...)?
Could memory be allocated in function Func() like this?
ThisPtr = new char[6];
Or something? How could something like that be done?
Sorry for all the questions but once i get it in my head that i want to know something, i want to know all about it.