Write something into the file
Earse the content of file sample.txt and write something new.
fptr = fopen("sample.txt", "w");
if (fptr == NULL)
printf("Cannot open file \n");
fopen() to open the specified file. "sample.txt" is file name. "w" denotes open it in write mode and earse the existing content. So write operation starts from begning.
Fprintf() writes the content into the file.
Note: sample.txt should exsist in the same folder where your program is located.