fn: read
[contents]

Contents

Syntax

The syntax for read calls is:

f++:  
read{option}(istream, params)

n++:  
@read{option}(istream, params)

Description

The read function is for reading input, it takes a non-zero number of parameters, the first parameter should be an input stream (either console, a file stream or a string stream), the remainder of the parameters should be either ofile where input is injected directly to the file being built or a variable name to read in to. Having one input parameter is the same as having a second parameter that is ofile. If not reading to the output file being built read will return whether or not it was successful.

Options

The following options are available for read calls:

option description
!r no return value
option description

f++ example

Examples of read being used with f++:

:=(string, s)
:=(int, i)
read(console, s, i)

:=(string, s)
:=(ifstream, ifs("input.txt"))
read(ifs, s, i)
ifs.close()

n++ example

Examples of read being used with n++:

@:=(string, s)
@:=(int, i)
@read(console, s, i)

@:=(string, s)
@:=(ifstream, ifs("input.txt"))
@read(ifs, s, i)
@ifs.close()