Thread: stream command....

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    28

    stream command....

    hi, my question is really simple. Im working with streams and i dont know the "end of file" command for c++ (i dont even know if there is such a thing) any help would be appreciated ;D

    oh and also, lemme know if this thinking is correct:
    i wanna do something like
    (pseudocode)

    while(!eof)
    read file to populate an Event vector (consisting of a string and a number)

    ive already populated a vector with a finite capacity but i wanna be able to "push_back" it to fill it with the entire content of the file.

    thanks
    the early bird gets the worm but the second mouse gets the cheese

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Code:
    if (!infile.is_open())
      return -1;
      while (infile.peek()!=EOF)
      {
    //read 
      }
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    28
    ty ty will try it when i get home ;D
    the early bird gets the worm but the second mouse gets the cheese

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Oh I just noticed I left that if(!infile.open()) there...it's good to check for that before you try to read, but make sure returning -1 works for wherever you put it in your code
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. IRC, reading the stream
    By Iyouboushi in forum C# Programming
    Replies: 6
    Last Post: 08-03-2006, 05:34 PM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. Ping problem
    By bladerunner627 in forum C++ Programming
    Replies: 12
    Last Post: 02-02-2005, 12:54 PM
  5. exe files in -c- language
    By enjoy in forum C Programming
    Replies: 6
    Last Post: 05-18-2004, 04:36 PM