Computer Science, asked by bhaleraosnehal2419, 4 months ago

Q. 6 Give the syntax of and explain various function related to ifstream and ofstream
classes seekp(), getline(), hide() tellp(), seekg().​

Answers

Answered by cutyruchi
3

The C language did not build the input/output facilities into the language. In other words, there is no keyword like read or write. Instead, it left the IO to the compiler as external library functions (such as printf and scanf in stdio library). The ANSI C standard formalized these IO functions into Standard IO package (stdio.h). C++ continues this approach and formalizes IO in libraries such as iostream and fstream.

Features

C++ IO is type safe. IO operations are defined for each of the type. If IO operations are not defined for a particular type, compiler will generate an error.

C++ IO operations are based on streams of bytes and are device independent. The same set of operations can be applied to different types of IO devices.

In C++ we have a get pointer and a put pointer for getting (i.e. reading) data from a file and putting(i.e. writing) data on the file respectively.

seekg() is used to move the get pointer to a desired location with respect to a reference point.

Syntax: file_pointer.seekg (number of bytes ,Reference point);

Example: fin.seekg(10,ios::beg);

Similar questions