14.09.2015 Views

Matvec Users’ Guide

Matvec Users' Guide

Matvec Users' Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5<br />

File Stream Control<br />

<strong>Matvec</strong> provides a class of input/out stream, which is a substantially limited C++ I/O stream system. A<br />

stream is a logical object associated with a physical device such as disk.<br />

When output is performed, data is not immediately written to the physical device associated with the<br />

stream. Instead, data is stored in an internal buffer until the buffer is full. However, data in the buffer can<br />

be forced out to disk before the buffer is full by using either endl() or flush(). Note that buffering is used to<br />

improve performance. Flushing each line of output using either endl() or flush() decreases efficiency.<br />

5.1 Standard File Streams<br />

There are three standard file streams created automatically each time when <strong>Matvec</strong> is invoked: cout, cin,<br />

cerr.<br />

5.1.1 cout<br />

not yet available<br />

5.1.2 cin<br />

not yet available<br />

5.1.3 cerr<br />

not yet available<br />

5.2 User Specified File Stream<br />

5.2.1 Creation<br />

f = FileStream("","") creates an object of class FileStream and assign to f. The<br />

"" can be either relative or absolute, and the "" must be one the following or appropriate<br />

combination: out, in, app, noreplace.<br />

5.2.2 Example<br />

> f = FileStream("try.out","out");<br />

> f.out("I am testing MATVEC file stream\n");<br />

> Pi=3.14159;<br />

> f.out("Pi = ", Pi, " 2*Pi = ", 2*Pi,"\n");<br />

39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!