1. fputs(): – this function is used to write a sequence of characters in given file. It takes two arguments: First, string is to be written. Second, file pointer.
2. fgets(): – This function is used to read a sequence of characters until it reaches one of the following:
- At the new line.
- Maximum number of characters which are specified by the programmer.
- At the end of the file(EOF).
- Reading and writing one block at a time: – Data can be accessed in a block. Block is an array. If you want to read a block then number of elements are need to be specify.
Function for reading/writing a block is:
- fread(): -This function is used to read one or more structures and it takes four arguments: First, pointer location. Second, each structure has a size and size is need to be specified here, which must be in bytes. Third, number of item to be read. Fourth, file pointer variable.
2. fwrite(): –This function is same as fread() it takes the same number of argument and syntax, but instead of reading elements from an array it writes element to the array.
Two functions are used for it:
1. getw(): – it is used to read integer value from specified file. It takes one argument i.e. Pointer to file.
2. putw(): – it is used to write integer value on specified file and takes two arguments.