What does the g stand for in gcount, tellg and seekg?

  • A+

What does the g stand for in std::iostream's gcount, tellg and seekg members?

Why aren't they called just count, tell and seek?


In streams supporting both read and write, you actually have two positions, one for read (i.e. "get" denoted by "g") and one for write (i.e. "put" denoted by a "p").

And that's why you have a seekp (inherited from basic_ostream), and a seekg (inherited from basic_istream).

Side note: The language C has - in contrast to C++ - only one such function fseek for both pointers; There it is necessary to re-poition the pointer when switching from read to write and vice versa (cf., for example, this answer). To avoid this, C++ offers separate functions for read and write, respectively.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: