Just a quick question out of curiosity

Has anyone ever attempted writing a complex program on a single line to see if he or she could do it?
Not really complex but meh, it's single line

1
2
3
4
int size (char *p)
{
    return (*p ? (1 + size(++p)) : 0);
}


400 posts whoop whoop
Last edited on
@Smac
That's an error if p is null http://ideone.com/cMnCRj
test the pointer instead http://ideone.com/1UG2qr
Aha, nice nice, thanks for that

E: Another

1
2
3
4
bool isp_2(int num)
{
    return (((num-1) & 1) & (!((num - 1) & num)));
}
Last edited on
Topic archived. No new replies allowed.