view tests/mini/foreach10.d @ 1651:cb960b882ca3 default tip

bindings were moved to dsource.org/projects/bindings/
author Moritz Warning <moritzwarning@web.de>
date Thu, 20 May 2010 20:05:03 +0200
parents 8baf611f0009
children
line wrap: on
line source

module foreach10;

extern(C) int printf(char*, ...);

void main() {
    char* last = null;
    printf("The addresses should increment:\n");
    foreach (ref c; "bar") {
        auto a = {
            printf("%x '%c'\n", c, c);
            return &c;
        };
        auto nw = a();
        printf("ptr = %p\n", nw);
        if (last != null)
            assert(nw == last+1);
        last = nw;
    }
}