cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Put stream pointer in chosen line
Put stream pointer in chosen line
Aug 8, 2010 at 5:08pm UTC
tirwit
(6)
Hi!
I need to concatenate several data files into one file, but in each source file the data only begins at the 6th line, so I want to start reading from that line. Is there a function that puts the stream pointer directly in that line?
Aug 8, 2010 at 6:11pm UTC
hamsterman
(4538)
New line is only marked by '\n', so you'll have to find 5 of them.
You could call getline 5 times
Or you could do this:
1
2
for
(
int
line = 1; line < 6;)
if
(file.get() ==
'/n'
) line++;
Aug 8, 2010 at 7:58pm UTC
tirwit
(6)
Strange... I thought it would be logical to exist one function to put the stream pointer in the beginning of a line.
Too bad... :(.
Thanks anyway hamsterman
Topic archived. No new replies allowed.