Recursive Complexity

Thoughts and musings of a programmer and wanna be entrepreneur

Archive for March 2013

Find Direction Of Growth Of Stack In C

leave a comment »

#include <stdio.h>

typedef unsigned long long UINT64;

UINT64 f(int b){
    return (UINT64)&b;
}

bool downwards(int a)
{
    int b = 0;

    if ((&a - f(b)) < 0)
        return false;
    else
        return true;
}

int main(int argc, char* argv[])
{
    int a = 0;

    if (downwards(a))
        printf("Downwards\n");
    else
        printf("Upwards");

    return 0;
}
Advertisements

Written by Vivek S

March 27, 2013 at 5:07 am

Posted in Tech

Tagged with , ,

TED Blog

The TED Blog shares interesting news about TED, TED Talks video, the TED Prize and more.