Say a function takes a void pointer as an argument, like so: int func(void *p);
How can we determine or guess the type of what p is pointing to?
Say a function takes a void pointer as an argument, like so: int func(void
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, you can’t. In some cases, if there is a guarantee on what p points to, you may be able to look at the contents at and after that address to find out. Generally, your function should know what it’s being passed, unless it just passes it along.
Data and function arguments in C are just a bunch of bits lumped together. Unless you use some of those bits to tell you what the bits are, there’s no consistent way to identify it.