Member functions (Extraction Operators) that are commonly used in ASCII file operations

Member functions (Extraction Operators) that are commonly used in ASCII file operations

The functions ‘istream‘ and ‘ostream‘ are member functions that are commonly used in ASCII file operations, and that are known as “Extraction Operators“.

Both ‘istream‘ and ‘ostream‘ are important classes from which input and output operations respectively, or read and write operations respectively are sourced. Stemming from ‘istream‘ and ‘ostream‘, many classes are derived, including the ‘ifstream‘, ‘ofstream‘ and ‘fstream‘ also for reading and writing to text and binary files as well as opening and closing text and binary files.

 

[istream]

istream::operator>> getline(istream& is, string& str);

For the ‘istream‘ class, the member function used commonly with ASCII file operations is the stream extraction operator (operator >>) whose functionality can be substituted by the function ‘getline()‘ with parameters ‘istream‘ and ‘string‘.

istream” or “is” represents the object we want to read into, while the “string” represents the object where the read data will be stored.

 

[ostream]

ostream::operator<< (ostream& os, char c / char * s)

For the ‘ostream‘ class, the member function used commonly with ASCII file operations is the stream insertion operator (operator <<) with parameters “ostream” and “char c / char * s“.

ostream” or “os” represents the stream object into which characters or a stream of characters will be inserted, while “char c” represents the characters to insert and “char * s” represents a pointer to null-terminated c-string (sequence of characters).

 

Member functions (Extraction Operators) that are commonly used in ASCII file operations
C++ | thetqweb