No products in the cart.

Explain the use of seekp and …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Explain the use of seekp and seeek g,tellp%tellg functions in data file handling

 

  • 1 answers

Naveen Sharma 7 years, 10 months ago

  1. seekg : Sets the position of the get pointer. The get pointer determines the next location to be read in the source associated to the stream. 

Syntax: seekg ( position );
Using this function the stream pointer is changed to the absolute position (counting from the beginning of the file).
seekg ( offset, direction );
Using this function, the position of the get pointer is set to an offset value relative to some specific point determined by the parameter direction. offset is of the member type off_type, which is also an integer type. And direction is of type seekdir, which is an enumerated type (enum) that determines the point from where offset is counted from.

2. seekp The seekp method changes the location of a stream object's file pointer for output (put or write.)  In most cases, seekp also changes the location of a stream object's file pointer for input (get or read.)
seekp ( position );
Using this function the stream pointer is changed to the absolute position (counting from the beginning of the file).
seekp ( offset, direction ); 
Using this function, the position of the put pointer is set to an offset value relative to some specific point determined by the parameter direction. offset is of the member type off_type, which is also an integer type. And direction is of type seekdir, which is an enumerated type (enum) that determines the point from where offset is counted from 


3. tellg The tellg() function is used with input streams, and returns the current "get" position of the pointer in the stream.
Syntax:  pos_type tellg();
It has no parameters and return a value of the member type pos_type, which is an integer data type representing the current position of the get stream pointer.

4. tellp : Returns the absolute position of the put pointer. The put pointer determines the location in the output sequence where the next output operation is going to take place. 
Syntax: pos_type tellp();

The tellp() function is used with output streams, and returns the current "put" position of the pointer in the stream. It has no parameters and return a value of the member type pos_type, which is an integer data type representing the current position of the put stream pointer.

http://mycbseguide.com/examin8/

Related Questions

What are called tokens
  • 2 answers
What is mean by buffering in file handling?
  • 1 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App