Just a quick question out of curiosity

Apr 5, 2013 at 2:14am
Has anyone ever attempted writing a complex program on a single line to see if he or she could do it?
Apr 5, 2013 at 4:54am
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 Apr 5, 2013 at 4:55am
Apr 5, 2013 at 5:03am
@Smac
That's an error if p is null http://ideone.com/cMnCRj
test the pointer instead http://ideone.com/1UG2qr
Apr 5, 2013 at 5:48am
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 Apr 5, 2013 at 6:19am
Topic archived. No new replies allowed.