Bonkers

Nicholas Clark nick at ccl4.org
Thu May 10 23:09:23 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  

I think I'd argue that it's a wrong answer.
Unless it's an assembler test.

I read online that in tech screening interviews Google ask C programmers
questions relating to those types of bit operation tricks, and I'm really
not convinced that any sane C programmer should be using them.

> 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');

er, why not strlen() and then a pointer addition?
That's not the first time I've seen that idiom, but I can't see how an
implementation of strchr() is going to be tighter than one of strlen()

Nicholas Clark


More information about the london.pm mailing list