| | |
how do read last file
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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.
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.
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?
.
....
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.
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
(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.
![]() |
Similar Threads
- Move file pointer to read next file value (C++)
- read from file help (C++)
- write and read to file (C++)
- how to read a file from client side without browsing (ASP.NET)
- C++ How can read from file.txt & where can save this file(file.txt) to start reading (C++)
- create, write & read file to/from folder (C++)
- Read in a file and store in char array (C)
Other Threads in the C Forum
- Previous Thread: Passing struct arrays to other functions
- Next Thread: C help with Eclipse
| Thread Tools | Search this Thread |
Tag cloud for C
#include adobe ansi array arrays asterisks binarysearch calculate centimeter changingto char convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware highest histogram inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv repetition research reversing scanf scripting segmentationfault sequential shape socket socketprograming stack standard string strings structures systemcall testing threads turboc unix user variable voidmain() wab windows.h windowsapi






