Clearest way to read and print .txt file lines in C
There are a bunch of ways describing how to use various methods to print out lines of a text file on this site: Posix-style , reading IP addresses , Fixed line length . They all seem to be tailored to a specific example. It would be great to have the Clearest and Most Concise and Easiest way to simply: print each line of any text file to the screen. Preferably with detailed explanations of what each line does. Points for brevity and clarity. #include <stdio.h> static void cat(FILE *fp) { char buffer[4096]; size_t nbytes; while ((nbytes = fread(buffer, sizeof(char), sizeof(buffer), fp)) != 0)