how do read last file

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 128
Reputation: sivak has a little shameless behaviour in the past 
Solved Threads: 0
sivak sivak is offline Offline
Junior Poster

how do read last file

 
0
  #1
Apr 5th, 2009
i have one serial file
n1\n2\n2\n4\n5\n6\........n
want to read last file only in above file....can any one tell me how come/
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 96
Reputation: Dewey1040 is an unknown quantity at this point 
Solved Threads: 3
Dewey1040 Dewey1040 is offline Offline
Junior Poster in Training

Re: how do read last file

 
0
  #2
Apr 5th, 2009
huh?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,549
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1484
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: how do read last file

 
0
  #3
Apr 5th, 2009
We do not speak gobbledygook. Please explain with a better example and more explanation.

Generally, the only way to read the last item of a text file is to read the entire file.
Last edited by Ancient Dragon; Apr 5th, 2009 at 7:08 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 128
Reputation: sivak has a little shameless behaviour in the past 
Solved Threads: 0
sivak sivak is offline Offline
Junior Poster

Re: how do read last file

 
0
  #4
Apr 6th, 2009
read the full file..want to display onl last file
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,666
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: how do read last file

 
0
  #5
Apr 6th, 2009
sup dawg i herd you like to read, so we put some files in your files so you can read while you read

....

naw serosly, what are you saying?? are you saying you want to read the last LINE from your file?

is that it?


.
Last edited by jephthah; Apr 6th, 2009 at 6:11 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 128
Reputation: sivak has a little shameless behaviour in the past 
Solved Threads: 0
sivak sivak is offline Offline
Junior Poster

Re: how do read last file

 
0
  #6
Apr 6th, 2009
yes ..last line
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,666
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: how do read last file

 
0
  #7
Apr 6th, 2009
okay, then you do this:

(1) open the file using "fopen".
(2) use a while loop to read each line into a string buffer using "fgets" until a NULL is returned.
(3) when fgets returns a NULL, it means there are no more lines. the last line read will still be in your string buffer.

"fopen" and "fgets" are widely-used commands from the <stdio.h> standard library. you will find tons of examples on the various online references. here is a good one: http://www.cplusplus.com/reference/c...dio/fgets.html
Last edited by jephthah; Apr 6th, 2009 at 11:31 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,625
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 205
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: how do read last file

 
0
  #8
Apr 6th, 2009
Just curious. . you posted a link to a c++ website. The use of that function is the exact same in c++ and c?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,666
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: how do read last file

 
0
  #9
Apr 6th, 2009
C++ is a superset of C. that website covers C++ and C. the referenced <stdio.h> library is standard C.

hey... wait a minute. if you're the best jew since jc, shouldnt you be omniscient?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 128
Reputation: sivak has a little shameless behaviour in the past 
Solved Threads: 0
sivak sivak is offline Offline
Junior Poster

Re: how do read last file

 
0
  #10
Apr 7th, 2009
i did the same ..error is coming..can u explain me in coding ? plz
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC