Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Foreach with a char![]

Part of ForeachCategory

Description

Shows using foreach with a dynamic char array.

Example

import std.stdio;
import std.string;

void main () {
  char[] names = "200 digitalmars.com InterNetNews NNRP server INN 2.3.2 ready (posting ok).
Sending List request.....
215 Newsgroups in form \"group high low flags\".
c++ 0000003792 0000000001 y
D 0000025479 0000000001 y
D.gnu 0000000488 0000000001 y
DMDScript 0000000040 0000000001 y
c++.beta 0000000357 0000000001 y
c++.stlsoft 0000000188 0000000001 y
c++.wxwindows 0000000172 0000000001 y";

  foreach (x; split(names,"\n"))
    writefln("x = %s", x);
}

Source

Inspired by D/25475.