Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getline question

Status
Not open for further replies.

SpongeBob1

Programmer
Mar 1, 2002
49
0
0
US
Hi,

How can I modify the following to go backwards in a file, as opposed to forwards?

skip = 7
for (i=1; i < lines2skip; i++){
getline;
print

SB
 
you can't - there's no &quot;ungetline&quot;.

You'll have to change your processing logic - the most straight forward approach is to save lines as they're being processed and &quot;back reference&quot; them as needed. vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I get you Vlad, so pipe to something & use getline to read them back in again? Or an array - that much I can do - the backreferencing I will have problems with, and tips for starting this?
 
the 'backreferencing' will be done through &quot;associative&quot; array populated as the file 'read in'.

One thread you might be interested in [although NOT directly related to he issue at head] is: thread271-397032

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top