C quiz questions/answers?

Michael Wittman plug-devel@lists.PLUG.phoenix.az.us
Fri Nov 9 17:10:30 2001


On Mon, Nov 05, 2001 at 03:17:00PM -0700, Rob Wehrli wrote:
> I've been writing an C "test" and thought that I'd ask the list for any
> good traps/questions they might have...but not without at least offering
> one.

Part of this one bit me not too long ago...  Anyone want to guess the
output?


#include <stdio.h>

void foo( char a[80] )
{
   char b[80] = "Hello world!";
   char *c = "bar";

   printf("sizeof(a) = %d\n",sizeof(a));
   printf("sizeof(b) = %d\n",sizeof(b));
   printf("sizeof(c) = %d\n",sizeof(c));
}

int main( int argc, char *argv[] )
{
   foo("012345678901234567890123456789012345678");

   exit(0);
}


-Mike