Bonkers

Ash Berlin ash_cpan at firemirror.com
Fri May 11 11:01:26 BST 2007


Andy Armstrong wrote:
> On 10 May 2007, at 23:46, Nicholas Clark wrote:
> 
>> On Thu, May 10, 2007 at 11:22:46PM +0100, Ash Berlin wrote:
>>
>>> ISTR my solution to that exact question was:
>>>
>>> include <stdio.h>
>>> include <stdlib.h>
>>>
>>> char* reverse(char* str) {
>>>   int i, len = strlen(str), len_2 = len/2;
>>>
>>>   for (i=0; i < len_2; i++) {
>>>     char s = str[i];
>>>     str[i] = str[len-1-i];
>>>     str[len-1-i] = s;
>>>
>>>   }
>>> }
>>
>> I think that yours breaks on an empty string.
> 
> I don't think it does. The loop never executes if len is zero.
> 
> I think it breaks by claiming to return a char * but then being void.
> 

That what you get for writing from memory and not compiling :)


More information about the london.pm mailing list