A stream is simply a flow of data or characters. There are two types of streams: input streams and output streams. An input stream is used to read the data from an external input device such as a keyboard, while an output stream is used to write data to the external output device such as a monitor. A file can be considered as both an input and output source.
In this article, there are several examples showing various ways to write text to a file. The first two examples use static convenience methods on the System. The third example shows how to add text to a file when you have to process each line individually as you write to the file. In the first three examples, you overwrite all existing content in the file.
Write a C program to create a file and write contents in it. How to create a file in C programming? C program to input a string from user and store it in a text file. Learn how to create a file and write contents to it in C programming. Basic input and output , Pointers , Structures, File handling.