Thread: File I/O problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    Jun 2005
    Posts
    594
    Quote Originally Posted by Narf
    I added the test for eof after the loop so that you can tell how the loop broke. If it broke on end of file then you're solid. If not, some funky error happened--like a device error or something equally devastating--and you may need to deal with it. Most people don't bother with that though and just assume that when the loop breaks, it's because of end of file.

    im sure if that happens the last concern they will have is if it the
    program completed successfully before everything crashed.

  2. #2
    Nonconformist Narf's Avatar
    Join Date
    Aug 2005
    Posts
    174
    im sure if that happens the last concern they will have is if it the program completed successfully before everything crashed.
    You do realize that there's an error or two between 'perfect operation' and 'thermonuclear meltdown' that would take full advantage of such a test?
    Just because I don't care doesn't mean I don't understand.

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    i dont see your point, my point is if the hardware stops function
    due toa device drive causeing a crash or not working anymore.
    or the hardware actually breaking down, the file is not going
    to be read? and the program may not even continue to run.

  4. #4
    Nonconformist Narf's Avatar
    Join Date
    Aug 2005
    Posts
    174
    i dont see your point
    Clearly.
    my point is if the hardware stops function
    due toa device drive causeing a crash or not working anymore.
    or the hardware actually breaking down, the file is not going
    to be read? and the program may not even continue to run.
    Okay, let's think of it in a light that's easier to follow. Say the stream operates on a file that's on a floppy, and the floppy is removed during an input or output operation. This won't cause the program to crash, but it will cause the badbit to be set for the stream. The loop will end, and if you assume it's because of end of file, data might be lost even though the program is still running. I'm sure you'll agree that data loss is a bad thing. And if you don't know about it, you can't fix it.
    Just because I don't care doesn't mean I don't understand.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  2. File i/o problem
    By tezcatlipooca in forum C++ Programming
    Replies: 18
    Last Post: 01-01-2007, 09:01 AM
  3. File I/O problem
    By Onions in forum C++ Programming
    Replies: 41
    Last Post: 02-24-2006, 04:32 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM