[Master Answer Logo]
Question

How do I read a file in C?

Answer

In UNIX an end-of-file indication can be sent from an interactive shell (console) by typing Ctrl+D (conventional standard). In Microsoft's DOS and Windows it is sent by pressing Ctrl+Z. In certain cases when dealing with text files or reading data from a "character device", the Microsoft MS-DOS shell (COMMAND.COM) or operating-system utility programs would historically append an ASCII control-Z character to the end of a disk file (though the basic kernel MSDOS.SYS file write calls never appended a control-Z). This was done for backward compatibility with some of the peculiarities of CP/M, since the CP/M filesystem only recorded the lengths of files in terms of how many 128-byte "records" were allocated. The MS-DOS filesystem has always recorded the exact byte-length of files from its very first version.

— Source: Wikipedia (www.wikipedia.org)