This section demonstrates you to write the data into the file.
Here we are using the library function fwrite() to write the data into the file. You can see in the given example, we have stored the string into the buffer which is to be written into the specified file 'Hello.txt'. The type FILE stores all the information related to file stream. The function fopen(file, "w") opens the file and allow to perform write operations into the file. The library function strlen() provided by the header file <string.h> determines the length of the string which is stored into buffer. The function fwrite(buffer, len, 1, p) write the buffer value into the file and fclose() function closes the file stream and flushes the buffer.
Here is the code:
When you run the above example, the string will get stored into the file and shows the message:
Recommend the tutorial