About
Pricing
Community
Teams
Start Free Trial
Log in
naseeam
asked on
7/13/2011
Can void pointer be casted to char and then re-casted to void?
void * ptr;
Can ptr be casted to pointer to char. Then, can it be re-casted to pointer to void?
C
3
1
Last Comment
evilrix
8/22/2022 - Mon
evilrix
7/13/2011
Yes.
naseeam
7/13/2011
ASKER
I don't think ptr needs to be re-casted to void because eventhough we casted it to char, it's still a void pointer, isn't it?
Example:
void somefunc(void * some_ptr);
void * ptr;
char * some_ptr;
some_ptr = ((char *)ptr)++;
/* I shouldn't need to recast ptr to void before passing it as an argument to a function */
somefunc(ptr); /* will this work? */
ASKER CERTIFIED SOLUTION
evilrix
7/13/2011
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck