The fclose function takes a file pointer as an argument. The file associated with the file pointer is then closed with the help of fclose function. It returns 0 if close was successful and EOF end of file if there is an error has occurred while file closing.
Closing a file manually by writing fclose function is a good programming practice. The process is to take each character of the array and write it into the file. These are the simplest file operations. Getc stands for get character, and putc stands for put character.
These two functions are used to handle only a single character at a time. Skip to content. To understand all programs on this page, you should have the knowledge of the following topics. Previous Tutorial:. Next Tutorial:. Share on:. Did you find this article helpful? Sorry about that. How can we improve it? Leave this field blank. Related Tutorials. The fprintf is used to write formatted output to stream. It is used to write a set of characters into a file. This is the C string that contains the text to be written to the stream.
It can optionally contain format tags,that are replaced by the values specified in subsequent additional arguments. The fputs writes the string pointed to by str to the stream pointed to by stream. In C, we use a structure pointer of a file type to declare a file:. In a UNIX system, everything is treated as a file, meaning you can read from and write to it.
This means that your printer can be abstracted as a file since all you do with a printer is write with it. When you call printf , you are really just writing to a special file called stdout , short for standard output.
This explains why it printed to your screen. There are two other streams i.
0コメント