Stig Brautaset stig at
Thu May 10 23:39:55 BST 2007

On 10 May 2007, at 23:09, Nicholas Clark wrote:
> 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.

I concur.

>> 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()

It was merely the first thing that came to my mind. You're right,  
strlen() would have been a better choice.


More information about the mailing list