Bonkers
Nick Cleaton
nick at cleaton.net
Fri May 11 08:17:46 BST 2007
On Thu, May 10, 2007 at 10:50:54PM +0100, Stig Brautaset wrote:
>
> No, I was not intending the xor-trick. I don't like those types of
> questions. Rather, I'd try to see if they understood pointers enough
> to get rid of the index variables. Something like the following:
>
> #include <stdio.h>
> #include <string.h>
>
> int main(void)
> {
> char s[] = "hello world";
>
> char *h = s;
> char *t = strchr(s, '\0');
> while (h < t) {
> char c = *h;
> *h++ = *--t;
> *t = c;
> }
>
> puts(s);
>
> return 0;
> }
When I'm the interviewer, I'm always tempted to take the
questions as far as I can, so I'd be asking the candidate for
a way to make that code run a little bit faster, and giving
hints if they don't know. Even if the job is unlikely to
revolve around speed critical C coding.
Sometimes I think this is a mistake, because some candidates
can get frustrated when asked stuff that they don't know, and
start to get annoyed if they think the question is irrelevant
or too artificial.
I suppose being evaluated on technical ability can be quite
emotionally charged, for someone who takes pride in it.
Nick
More information about the london.pm
mailing list