Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between basic_istream<>::tellg() and basic_ostream<>::tellp() [closed]

Tags:

c++

filestream

I was just wondering why the member functions tellg() defined in basic_istream<> class and tellp() defined in basic_ostream<> class have different names. Is that because basic_fstream<> is derived from basic_istream<> and basic_ostream<> ?

like image 555
John Kalane Avatar asked Jan 25 '13 12:01

John Kalane


People also ask

What is the difference between Tellg () and Tellp () functions?

tellg() get the position of the get pointer and tellp() gets the position of the put pointer, one of them is the place where you read and the second- where you write in the file. So the two functions do different things and return different values.

What is the difference between Tellg and Tellp in C++?

tellp() gives the position of the put pointer. tellg() gives the position of the get pointer.

What does Tellg () function return?

tellg() function in C++ with example The tellg() function is used with input streams, and returns the current “get” position of the pointer in the stream. It has no parameters and returns a value of the member type pos_type, which is an integer data type representing the current position of the get stream pointer.

What does Tellp return in C++?

In C++ file handling, the tellp() function is used with output streams, and returns the current put position of the pointer in the stream. It returns an integer data type, representing the current position of the stream pointer. tellp() method takes no parameter.


1 Answers

tellg() get the position of the get pointer and tellp() gets the position of the put pointer, one of them is the place where you read and the second- where you write in the file. So the two functions do different things and return different values. Why would you think they should have the same name?

like image 86
Ivaylo Strandjev Avatar answered Oct 12 '22 01:10

Ivaylo Strandjev