C++ how to add/subtract tellp(), tellg() return
问题 Say I wanted to get the difference (in int) between two tellp() outputs. The tellp() output could be huge if a big file is written so it is not safe to say store it inside a long long. Is there a safe way to perform a operation like this: ofstream fout; fout.open("test.txt",ios::out | ios::app); int start = fout.tellp(); fout<<"blah blah "<<100<<","<<3.14; int end = fout.tellp(); int difference = end-start; Here, I know that the difference between end and start can definitely fit in an int.