If you want to learn input and output in C, start by looking at the stdio.h include file. As you might guess from the name, that file defines all the standard (“std”) input and output (“io”) functions.

The first stdio.h function that most people learn is the printf function to print formatted output. Or the puts function to print a simple string. Those are great functions to print information to the user, but if you want to do more than that, you’ll need to explore other functions.

You can learn about some of these functions and methods by writing a replica of a common Linux command. The cp command will copy one file to another. If you look at the cp man page, you’ll see that cp supports a broad set of command-line parameters and options. But in the simplest case, cp supports copying one file to another:

cp infile outfile

You can write your own version of this cp command in C by using only a few basic functions to read and write files.

#c #input #output

Learn how file input and output works in C
1.20 GEEK