Basic input and output

Julia's vision on input/output (I/O) is stream-oriented, that is, reading or writing streams of bytes. We will introduce different types of stream, file streams, in this chapter. Standard input (stdin) and standard output (stdout) are constants of the TTY type (an abbreviation for the old term, Teletype) that can be read from and written to in Julia code (refer to the code in Chapter 8\io.jl):

  • read(stdin, Char): This command waits for a character to be entered, and then returns that character; for example, when you type in J, this returns 'J'
  • write(stdout, "Julia"): This command types out Julia5 (the added 5 is the number of bytes in the output stream; it is not added if the command ends in a semicolon ;)

stdin and ...

Get Julia 1.0 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.