添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Hello.
I want to read the previous line with ifstream, while somewhere in the middle of the file.
How do I do this?
Thanks in advance. tellg Get position of the get pointer. (public member function)
seekg Set position of the get pointer (public member function )
fstream - C++ Reference
Use tellg() before you read a line, and store the answer somewhere.
Passing that value to seekg() will allow you to re-read the same line.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper .
tellg Get position of the get pointer. (public member function)
seekg Set position of the get pointer (public member function )
fstream - C++ Reference
Use tellg() before you read a line, and store the answer somewhere.
Passing that value to seekg() will allow you to re-read the same line.
Thanks.
That worked.
  • C++ Tutorial
  • 5 ways you can learn to program faster
  • The 5 Most Common Problems New Programmers Face
  • How to set up a compiler
  • 8 Common programming Mistakes
  • What is C++11?
  • Creating a game, from start to finish Recent additions subscribe to a feed
  • How to create a shared library on Linux with GCC - December 30, 2011
  • Enum classes and nullptr in C++11 - November 27, 2011
  • Learn about The Hash Table - November 20, 2011
  • Rvalue References and Move Semantics in C++11 - November 13, 2011
  • C and C++ for Java Programmers - November 5, 2011
  • A Gentle Introduction to C++ IO Streams - October 10, 2011
  •