Well, AN answer, at any rate. Click through if you want to see it, but hold off if you want to try it out for yourself.

#include <stdio.h>

int printreverse(char* string) {
    return (*string) && (printreverse(string+1) | printf(\"%c\", *string));

The basic idea (to use logical operators to short-circuit recursion) came from one of my teammates who was at the espresso bar with us, and I used it as a starting point. Like most C programs you might have to stare at it for a while before you figure out how it works 😛

Leave a Reply

Your email address will not be published. Required fields are marked *