#void pointer casting help
9 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
void pointer casting help
Looks good to me but you can just try it:
;compile
#include <stdio.h>
void *foo() {
return (void *) "abc";
}
int main(void) {
char *s = "abc";
printf("%c%c", ((char *) foo())[0],
((char *) foo())[1]);
}
Program Output
ab
Samu#6425 | 40ms | c | x86-64 gcc 12.2 | godbolt.org
alright tysm for the help!
If your function returns NULL it will crash though.
!solved