Skip to main content

Posts

Showing posts with the label File handling

File handling functions

fopen() FILE *fopen(const char *path, const char *mode); The fopen() function is used to open a file and associates an I/O stream with it. This function takes two arguments. The first argument is a pointer to a string containing name of the file to be opened while the second argument is the mode in which the file is to be opened. The mode can be : ‘r’    :  Open text file for reading. The stream is positioned at the beginning of the file. ‘r+’ :  Open for reading and writing. The stream is positioned at the beginning of the file. ‘w’   :  Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. ‘w+’ : Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. ‘a’    : Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at th...