QuickC

Turgut Kalfaoglu TURGUT at TREARN.BITNET
Fri Aug 26 19:10:07 AEST 1988


The other day, I was struggling with QuickC - a very simply problem,
but really intriguing. Let me know if you can interpret this:

main()
{
   int a,v;
   a = 2;
   v = square(a);
   printf("%d\n",v);
}

square(num)
int num;
{
  num = num*num;
}

OK? There is no 'return' statement in the function. However, it works!
I get '4' as an answer. So I thought maybe it was keeping the result
of the last operation, so I added some dummy lines,

square(num)
int num;
{
  int dummy;
  num = num*num;
  dummy=222;
}

but the call STILL works... Can anyone shed some light onto this?
WHY does it work?
-turgut



More information about the Comp.lang.c mailing list