dinarko
dinarko

Reputation: 1

Read text from .txt file started from other line

How I can read text from file, but not from 1. line. For example in text file is written-

1| Hello
2| !
3| 2021
4| 18
5| 03

But I want that program read text from line number 3 (2021....), bet then read next line.

But how I could do it? C++

Upvotes: 0

Views: 43

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596256

You can open the file using std::ifstream, use its ignore() method to skip the first 2 lines, and then use std::getline() to read the 3rd line.

Upvotes: 1

Related Questions