The OpenD Programming Language

readln

* Read line from stdin and write it to buf[], including terminating character. * * This can be faster than line = readln() because you can reuse * the buffer for each call. Note that reusing the buffer means that you * must copy the previous contents if you wish to retain them. * * Returns: * size_t 0 for end of file, otherwise number of characters read * Params: * buf = Buffer used to store the resulting line data. buf is resized as necessary. * terminator = Line terminator (by default, '\n'). Use std.ascii.newline * for portability (unless the file was opened in text mode). * Throws: * StdioException on I/O error, or UnicodeException on Unicode conversion error. * Example: * Reads stdin and writes it to stdout.

import std.stdio;

void main()
{
    char[] buf;
    while (readln(buf))
        write(buf);
}
  1. S readln(dchar terminator)
  2. size_t readln(C[] buf, dchar terminator)
  3. size_t readln(C[] buf, R terminator)
    size_t
    readln
    (
    C
    R
    )
    (
    ref C[] buf
    ,)
    if (
    is(Unqual!C == C)
    &&
    !is(C == enum)
    &&
    isBidirectionalRange!R
    &&
    is(typeof(terminator.front == dchar.init))
    )

Meta