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

I/O on stdin and stdout

Part of StandardLibraryCategory

Description

A very simple example of I/O on stdin and stdout.

It uses streams instead of stc.c.stdio calls.

Example

import std.cstream : din, dout ;
import std.string  : toupper   ;

int main () {
  char[] input  ,
         output ;

  // Ask for a string
  dout.writeLine("Converts a lowercase string to uppercase.");
  dout.writeLine("Please enter a string:");
  input = din.readLine();

  // Convert to upper and print it
  output = input.toupper();
  dout.writeLine(output);

  return 0;
}

Version

This example is "up-to-date" as of DMD 0.163 and may present problems with earlier or later versions.