The fwrite() function
The fwrite() function is used to write records (sequence of bytes) to the file. A record may be an array or a structure.
fwrite( ptr, int size, int n, FILE *fp );
Enter Roll : 1 Enter Name : Ashish Enter Marks : 78.53 Do you want to add another data (y/n) : y Enter Roll : 2 Enter Name : Kaushal Enter Marks : 72.65 Do you want to add another data (y/n) : y Enter Roll : 3 Enter Name : Vishwas Enter Marks : 82.65 Do you want to add another data (y/n) : n Data written successfully...
The fread() function
The fread() function is used to read bytes form the file.
fread( ptr, int size, int n, FILE *fp );
Roll Name Marks 1 Ashish 78.53 2 Kaushal 72.65 3 Vishwas 82.65