type: ofstream
[contents]

Contents

Syntax

The syntax for ofstream definitions is:

f++:  
ofstream definitions
ofstream(definitions)
:=(ofstream, definitions)

n++:  
@ofstream definitions
@ofstream(definitions)
@:=(ofstream, definitions)

Note: If you are using the first syntax for variable definitions and want to have more code and/or text following on the same line then simply end the definition with ';'.

Description

The ofstream type is used for output file streams.

Note: If you need to define thousands of variables then := is faster, plus it has useful error messages for unrecognised types.

Member functions

The following member functions are available for ofstream variables:

option description
close closes the file from writing
open(path) open a file to write to
option description

Options

The following options are available for ofstream definitions:

option description
const definition of a constant
layer="x" define variable at layer x
!mf do not add member functions for variables
private definition of a private
scope+="x" add x to scopes variable can be accessed from
option description

f++ example

Examples of ofstream being defined with f++:

ofstream ofs("output.txt")
write(ofs, "hello, world!", endl)
ofs.close()

n++ example

Examples of ofstream being defined with n++:

@ofstream ofs("output.txt")
@write(ofs, "hello, world!", endl)
@ofs.close()

Sponsors