readln

* Read line from stdin. * * This version manages its own read buffer, which means one memory allocation per call. If you are not * retaining a reference to the read data, consider the readln(buf) version, which may offer * better performance as it can reuse its read buffer. * * Returns: * The line that was read, including the line terminator character. * Params: * S = Template parameter; the type of the allocated buffer, and the type returned. Defaults to string. * terminator = Line terminator (by default, '\n'). * Note: * String terminators are not supported due to ambiguity with readln(buf) below. * 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()
{
    string line;
    while ((line = readln()) !is null)
        write(line);
}
  1. S readln(dchar terminator)
    S
    readln
    (
    S = string
    )
    (
    dchar terminator = '\n'
    )
  2. size_t readln(C[] buf, dchar terminator)
  3. size_t readln(C[] buf, R terminator)

Meta