fprintf is used to print content in file instead of stdout console.
int fprintf(FILE *fptr, const char *str, ...);
Example:
Input: GeeksforGeeks GeeksQuiz Output: sample.txt file now having output as 0. GeeksforGeeks 1. GeeksQuiz