import std.stdio; void foo(string x) { foreach (i, ch; x) writefln("x[%d] == '%c'", i, ch); } void main() { foo("hello world"); }
Standard input is empty
x[0] == 'h' x[1] == 'e' x[2] == 'l' x[3] == 'l' x[4] == 'o' x[5] == ' ' x[6] == 'w' x[7] == 'o' x[8] == 'r' x[9] == 'l' x[10] == 'd'