Thread: Help with redirection

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    8

    Question Help with redirection

    Hi everyone, I have a problem where when I do a redirection, I keep getting an infinite loop. Is there a way I can read a data file until it ends, and that ends the program? Right now, this is just a snippet of the code that loops a cin statement to keep the program running. If I wanted to "a.out < inputfile", it will continue going unless exit is somewhere in the file. Is there a way I can just use a eof() thingy or something similar that will stop running the loop if the end of the data file is reached? THanks in advance for any help

    Nornny

    Code:
      cin >> search;
      while (search != "exit") {
        dict.seek(search);
        cin >> search;
      }

  2. #2
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    Code:
      while (cin >> search) {
        dict.seek(search);
      }
    It reads until EOF.
    Nothing more to tell about me...
    Happy day =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 01:59 AM
  2. Linux file redirection buffering issue !!!!
    By AirSeb in forum Linux Programming
    Replies: 8
    Last Post: 03-14-2009, 05:32 PM
  3. Implement Redirection for a simple shell
    By koooee in forum C Programming
    Replies: 4
    Last Post: 02-22-2009, 03:21 PM
  4. General a.out redirection question under Linux
    By merixa in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2005, 05:36 PM
  5. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM