EOF in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thyagaraj315
    New Member
    • Sep 2007
    • 1

    EOF in C

    What is the value of EOF in C?
    i've written C program to read keypad values if it is not equal to EOF..
    But the program is not terminating even if i enter ESC key... only thing i can break the program by pressing ctrl+break...

    please tell me which key is for EOF in Turbo C
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    EOF is interpreted as End Of File.
    It's value is -1. It is defined in stdlib.h and stdio.h
    It is used in file operations. When file descriptor reaches at the end of file, this value gets assigned to it.

    Comment

    • mschenkelberg
      New Member
      • Jun 2007
      • 44

      #3
      On the terminal EOF is interpreted as Ctrl-d

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by ashitpro
        EOF is interpreted as End Of File.
        It's value is -1. It is defined in stdlib.h and stdio.h
        It is used in file operations. When file descriptor reaches at the end of file, this value gets assigned to it.
        Don't be so sure about that -1; this is what the Standard has to say about it:

        Originally posted by C Standard

        EOF

        which expands to an integer constant expression, with type
        int and a negative value, that is returned by several
        functions to indicate end-of-file, that is, no more input
        from a stream;
        kind regards,

        Jos

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by mschenkelberg
          On the terminal EOF is interpreted as Ctrl-d
          On Unix terminals that is; it is completely implementation event what type of event
          causes an end-of-file condition on the stream. btw, it's the other way around on
          Unix machines: ctrl-d is interpreted as an end-of-file condition.

          kind regards,

          Jos

          Comment

          • Ganon11
            Recognized Expert Specialist
            • Oct 2006
            • 3651

            #6
            I believe in Windows it is ctrl+z, though I could be wrong.

            Comment

            Working...