Thread: Move pointer to next line in .txt file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User motarded's Avatar
    Join Date
    Feb 2006
    Location
    Djibouti, Africa
    Posts
    14

    Move pointer to next line in .txt file

    I'm trying to select a value at random from a .txt document. Each value is on a separate line (I understand that the computer interprets that as Value 1\nValue 2\n Value3).

    Example.txt
    Code:
    WORD | SUBJECT
    WORD | SUBJECT
    WORD | SUBJECT
    WORD | SUBJECT
    I can pull the same word and subject without a problem. Is there anyway to randomly set the pointer to begin on a different line of the .txt file? Short of going through and finding all the pointer positions?

    I've already initialized rand() to a truly random number using srand(time(NULL)). I just can't figure out a way to move to a random line and return the information.

    To sum it up...is there anyway to move the pointer "vertically" by identifying '\n' chars?
    Last edited by motarded; 03-01-2006 at 06:47 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM