0

I am learning c++ and I keep running into a common problem: I cannot find the reasons behind function names.

For example, ifstream seekg() function. I attempt to look up the function on websites like:

http://www.cplusplus.com/reference/istream/istream/seekg/

https://en.wikipedia.org/wiki/Seekg

http://en.cppreference.com/w/cpp/io/basic_istream/seekg

Many times, none of these sources will give me a clue as to why it is named "seekg". Why is there a 'g' at the end? why does the ofstream have seekp (instead of g)?

Knowing that kind of information would make memorizing function names so much easier. Essentially, I'm looking for a resource for finding the etymology for function names. :)

Thanks for any help,

Enigma22134
  • 532
  • 5
  • 12
  • Cppreference has a habit of noting particularly obscure etymologies, like strpbrk and strcspn – Cubbi Jun 09 '16 at 20:15

1 Answers1

3

I can answer the specific question here. seekg refers to seek implemented over get area, while seekp works on put area.

The reason for the distinction is that streams support to separate areas - one is for reading, commonly refered to as source (get area), and another for writing, known as sink (put area). Quite often one works with streams which are limited to only one of those - std::ifstream only has get area, while std::ofstream has put area - but occasionally you deal with both.

SergeyA
  • 61,605
  • 5
  • 78
  • 137