Page 262 - DCAP404 _Object Oriented Programming
P. 262
dec Sets base 10 integers.
endl Sends a new line character.
ends Sends a null (end of string) character.
flush Flushes an output stream. Unit 12: Console I/O
fixed Sets fixed real number notation.
hex Sets base 16 integers.
Notes
oct Sets base 8 integers.
ws Discard white space on input.
setbase(int) Sets integer conversion base (0, 8, 10 or 16 where 0 sets base 10).
setfill(int) Sets fill character.
setprecision(int) Sets precision.
setw(int) Sets field width.
resetiosflags(long) Clears format state as specified by argument.
setiosflags(long) Sets format state as specified by argument.
The stream classes have a variety of member functions to give them their required functionalities.
Thus, there is a function to open the stream, one for reading/writing, one for closing the stream
and the like. The stream class member functions are listed below:
void .close() Closes the I/O object.
int .eof() Returns a nonzero value (true) if the end of the
stream has been reached.
char .fill(char fill_ch | void) Sets or returns the fill character.
int .fail() Returns a nonzero value (true) if the last I/O
operation on the stream failed.
istream& .get(int ch) Gets a character as an int so EOF (-1) is a possible
value.
istream& .getline(char* ch_string, int maxsize, Get a line into the ch_string buffer with maximum
char delimit) length of maxsize and ending with delimiter
delimit.
istream& .ignore(int length[, int delimit]) Reads and discards the number of characters
specified by length from the stream or until the
character specified by delimit (default EOF) is
found.
iostream& .open(char* filename, int mode) Opens the filename file in the specified mode.
int .peek(); Returns the next character in the stream without
removing it from the stream.
int .precision(int prec | void) Sets or returns the floating point precision.
ostream& .put(char ch) Puts the specified character into the stream.
istream& .putback(char ch) Puts the specified character back into the stream.
istream& .read(char* buf, int size) Sends size raw bytes from the buf buffer to the
stream.
long .setf(long flags [, long mask]) Sets (and returns) the specified ios flag(s).
long .unsetf(long flags) Clears the specified ios flag(s).
int .width(int width | void) Sets or returns the current output field width.
ostream& .write(const char* buf, int size) Sends size raw bytes from buf to the stream.
A file may be opened for a number of file operations. The corresponding stream must be set
with the intended operation. The different file stream modes are indicated by File Access Flags
as listed below:
LOVELY PROFESSIONAL UNIVERSITY 255