anatomy.c

#include <stdio.h>
#include <stdlib.h>


#define PP(_sym) pp(#_sym, &_sym)

void pp(char *prefix, const void *param)
{
    printf("\t%s\t%p\n", prefix, param);
}

int glob = 32;
int uninit;

int main(int argc, char *argv[])
{
    int foo;
    void *bar = malloc(100);
    const char *s = "foo";
    static int baz;

    printf("code segment:\n");
    PP(main);
    PP(pp);
    PP(printf);

    printf("stack:\n");
    PP(foo);
    PP(bar); // Oui oui c'est un stack regardez bien
    PP(baz);

    printf("arg segment ?:\n");
    PP(argc);
    PP(argv);

    printf("heap:\n");
    PP(*bar);

    printf("data segment (static)\n");
    PP(glob);
    PP(uninit);

    printf("data const segment\n");
    PP(*s);

    return 0;
}