Thread: reading data and outputting data on screen if more or previous is entered

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    44
    how would i go about writing a program that takes a txt file and printing the first 20 lines if i pressed m or pritning the previous 20 lines if i press p...is there an easy way to do this. any tips would be greatly appreciated. if you are showing me the pointer way can u plz explain in detail since im a newbie at pointers.
    Last edited by loso44x; 10-22-2005 at 01:13 AM.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    one way to do that is to keep track of the starting file position before reading the file (fgetpos() will do that), read and display 20 lines ( fgets() ) then wait for keyboard entry. If m is pressed, call fgetpos() again, read and display the next 20 lines. If p is pressed, call fsetpos() to reset the file position back to its previous position then read and display the next 20 lines.

    the only pointer involved is the FILE* pointer and the object needed by fsetpos() and fgetpos().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question regarding outputting data to adobe flash
    By hoax464 in forum C++ Programming
    Replies: 1
    Last Post: 07-21-2008, 01:08 PM
  2. Outputting data to ports
    By FwyWice in forum C++ Programming
    Replies: 1
    Last Post: 11-27-2002, 08:42 AM