[nycbug-talk] MSNBC on the decline of technology jobs

Michael Shalayeff mickey
Wed Jun 22 15:27:42 EDT 2005


Making, drinking tea and reading an opus magnum from Marc Spitzer:
[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> On 6/22/05, alex at pilosoft.com <alex at pilosoft.com> wrote:
> > On Wed, 22 Jun 2005, Francisco Reyes wrote:
> > 
> > 
> > If you want me to give examples in software development, my favorite
> > interview question is "c=0; c=c++;" what is the value of c?  The right
> > answer is 'undefined', it can be 0, 1, or 500. Now, its all about how
> 
> actually I would say 1, compilers may differ but according to what I
> remember of C, been years, it should be 1.  Here is why:

-- and ++ when used in an _expression_ along
w/ the lvalue itself produce undefined _order_
of execution.

so yes -- 500 is a totally wrong answer.
it might be 0 or 1.

> > someone thinks about resolving this: Break the statement into operations,
> > and try to figure whether assignment or post-increment will happen first.
> 
> by definition post incrament happens after assignment, again compilers
> may vary but that is how it should work

no
the post-ops (as well as pre-ops) happen after(before) the lvalue
is used therefore in case of '=' which is just another operator
in an expression there is no way to say where the pre/post op is executed.

> > It shows whether you know what expression is, what rvalue/lvalue is, what
> > the code is going to be *compiled* to, etc.
> > 
> > C has a lot of "gotchas" - if you don't know them and can't recognize
> > them, you'll fail my interview. I like to give examples that'd make a
> > difference between signed int/unsigned int, proper casting, why you
> > shouldn't use strcpy, why you shouldn't cast a pointer into an int. (Note:
> > just merely knowing that you *shouldnt* doesn't give you any points on
> > this test, you need to know why). Those questions I consider

here is a more fun one:
char c = 0xf0;
printf("%x\n", c << 16);

cu

-- 
    paranoic mickey       (my employers have changed but, the name has remained)




More information about the talk mailing list