Skip to content

Instantly share code, notes, and snippets.

@AndrewO
Created February 20, 2009 05:39
Show Gist options
  • Save AndrewO/67330 to your computer and use it in GitHub Desktop.
Save AndrewO/67330 to your computer and use it in GitHub Desktop.
// 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