|
-
November 28th, 2002, 12:40 AM
#1
Need Code for these
a c program to print last n lines if the text as well as n is specified in the program.
the following program reads a file from BOF to EOF. I am looking for a program for reading from EOF to the number of lines i specify.i Can reach the end of file by using FSEEK() how do i read the lines.
STORE FOPEN('test.txt') TO gnFileHandle && Open the file
STORE FSEEK(gnFileHandle, 0, 2) TO gnEnd && Move pointer to EOF
STORE FSEEK(gnFileHandle, 0) TO gnTop && Move pointer to BOF
IF gnEnd <= 0 && Is file empty?
WAIT WINDOW 'This file is empty!' NOWAIT
ELSE && If not
gcString = FGETS(gnFileHandle, gnEnd) && Store contents
? gcString
ENDIF
= FCLOSE(gnFileHandle) && Close the file
Last edited by Amandeep; November 29th, 2002 at 04:41 AM.
Regards,
Aman
-
November 28th, 2002, 12:41 AM
#2
1. Attempt the homework on your own.
2. If you have specific questions, ask. We'll be glad to help.
Jeff
-
November 28th, 2002, 12:11 PM
#3
Re: Need Code for these
Originally posted by Amandeep
a c program to print last n lines if the text as well as n is specified in the program.
What are you talking about? You want to print the last n lines
of what text? You can let the user pass 'n' into your program.
Research command-line arguments to programs ... more
specifically the arguments to main() argc and argv.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|