Thread: Strange EOF happenings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    15

    Strange EOF happenings

    For some reason, whenever the program reads 1A in hex, 26 in dec it is reading it as EOF. I have it print out the character and, sure enough, it prints -1. I don't get it. Other programs are detecting EOF just fine. Here's the culprit code:
    Code:
    new_byte = fgetc(_source);
       while(new_byte != EOF){
          decompress(new_byte, bit);
          for(i=0; i < (8/bit); i++){
             fputc(_new_pixels[i], _dest);
          }
          printf("%d: ", j);
          j++;
          new_byte = fgetc(_source);
          printf("%d\n", new_byte);
       }
    That is supposed to loop through over 8000 times, but it gets to byte number 206 and hit EOF. Here's the end of the output:

    Code:
    200: 0
    201: 0
    202: 15
    203: 255
    204: 139
    205: 47
    206: -1
    Byte number 206 is 26, not -1

    I changed byte 206 to 27, then it stopped on the next 26 later in the file.

    Any ideas?
    Thanks
    Last edited by fatinez; 09-23-2003 at 08:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. EOF Explanation Anybody?
    By blackcell in forum C Programming
    Replies: 1
    Last Post: 01-29-2008, 09:09 PM
  2. EOF or not EOF?
    By CornedBee in forum Linux Programming
    Replies: 2
    Last Post: 09-14-2007, 02:25 PM
  3. EOF messing up my input stream?
    By Decrypt in forum C++ Programming
    Replies: 4
    Last Post: 09-30-2005, 03:00 PM
  4. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  5. files won't stop being read!!!
    By jverkoey in forum C++ Programming
    Replies: 15
    Last Post: 04-10-2003, 05:28 AM