What Is The EOF Character In C?

by | Last updated on January 24, 2024

, , , ,

The EOF in C/Linux is

control^d

on your keyboard; that is, you hold down the control key and hit d. The ascii value for EOF (CTRL-D) is 0x05 as shown in this ascii table . Typically a text file will have text and a bunch of whitespaces (e.g., blanks, tabs, spaces, newline characters) and terminate with an EOF.

How can you tell if a character is EOF?

Fgetc() function returns a value of int type. Namely, it can return a number from 0 to 255 or -1 (EOF). The values read are placed into a variable of char type. Because of this, a symbol with the 0xFF (255) value turns into -1, and then is handled in the same way as the end of file (EOF).

What is EOF value in C?

EOF instead is a negative integer constant that indicates the end of a stream; often it’s

-1

, but the standard doesn’t say anything about its actual value. C & C++ differ in the type of NULL and ‘

Emily Lee
Author
Emily Lee
Emily Lee is a freelance writer and artist based in New York City. She’s an accomplished writer with a deep passion for the arts, and brings a unique perspective to the world of entertainment. Emily has written about art, entertainment, and pop culture.