Thread: Which characters represent EOF in windows?

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    Which characters represent EOF in windows?

    Hello to all,

    I just want to know which characters represent EOF.

    I am using TURBO C in WINDOWS.

    Using code when I printed it shows -1 but in the output screen when I use it, it does not seem to be EOF.

    Thanks for your support.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    EOF cannot be accurately represented by a char. Use an int to read characters if you need to test for EOF.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    It doesn't matter. Just use EOF when you want to check against EOF. There's no need to ever, ever, ever know what EOF is, because the standard doesn't say exactly what it'll be.

    But yeah, -1 is a common value implementors use
    If you understand what you're doing, you're not learning anything.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you're referring to how you type in an EOF, then pressing ctrl-z is usual for DOS/Windows.

    Eg.
    This is a line
    ctrl-z

    Would cause your program to see "This is a line\n" and then the EOF value
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    I'm using Dev-Cpp IDE with Mingw compiler and in my stdio.h I found that EOF is defined as:
    Code:
    #define	EOF	(-1)
    but you shouldn't be concerned about it. What is important is to use it effectively, please look at the FAQ.
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    I think the end-of-file marker in files opened in text mode is represented by 0x1A (26) character.

  7. #7
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    Please execute this code:
    Code:
    int main(void)
    {
        FILE *fp;
        int x, ret_val = 0;
        fp = fopen ("Test2.txt", "r");
        while ((ret_val = fscanf(fp, "%d",&x)) != EOF)
        {
            printf("%d ", x);
        }
        printf ("\n\n%d", ret_val);
        
        return 0;
    }
    where Test2.txt is in attachment.
    Tell me what is your output and which OS you're using!
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Viorel
    I think the end-of-file marker in files opened in text mode is represented by 0x1A (26) character.
    It doesn't matter what mode you open it in. EOF canno...wait a second! I already answered this!


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Some day, I swear I'm gonna write a libstdc with EOF as -0xE0F, just to throw all these idiots severely off track.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  10. #10
    Registered User
    Join Date
    Apr 2006
    Posts
    2
    I think EOF = Ctrl+C (on Windows).

  11. #11
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Quote Originally Posted by X.Cyclop
    I think EOF = Ctrl+C (on Windows).
    No. It doesn't. Not at all.

    This bad thread was so close to death, why try to revive it?
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  2. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  3. Network Programming in C for Windows
    By m.mixon in forum C Programming
    Replies: 7
    Last Post: 06-19-2006, 08:27 PM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  5. shutting down windows
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2002, 12:28 PM