Created
February 20, 2009 05:39
-
-
Save AndrewO/67330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Contrived example. Your f() is presumably correct and should be returning a pointer | |
// to an unsigned short | |
unsigned short *f() { | |
return (unsigned short *)"foo"; | |
} | |
// A simple g() that takes a pointer to a char and prints its string | |
void g(char *s) { | |
printf("Got: %s\n", s); | |
} | |
int main(void) { | |
// Behold, the magic of type coercions! :) | |
g((char *)f()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment