A little bit of C fun...
John Carter
john.carter@tait.co.nz
Wed Oct 22 22:04:00 GMT 2008
On Wed, 22 Oct 2008, Austin, Alex wrote:
> Oh, no... I'm dumb.
>
> typedef struct {
> int x;
> } b;
>
> int a(b *param)
> {
> return printf("%d\n", b->x);
> }
>
> int print_number(int c)
> {
> return a(&(b){c});
> }
Great! You've got it!
Now for extra credit...
Where would this trick be sort of useful?
> I shorten it by one character....
> a(&(b){})
>
> ... (but then it does something subtly more that the previous
> one...oooh I'm evil!)
What would your program print if you took out the c and why?
int print_number(void)
{
return a(&(b){});
}
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand
More information about the Gcc-help
mailing list