Check out the relevant information, summarized as follows:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 char money= ' s ' ; 7 char a = ' w ' ; 8 char b = ' e ' ; 9 char day= ' t ' ; 10 11 FILE *fp = fopen( " a.txt " , " a+ " ); // Open and create a write-only file at the specified location. 12 /* 13 FILE *fp = fopen("path","write mode"); 14 "w" => create and write (overwrite) 15 "a" => create and write (continuous write) 16 "a+" => create and write (line-by-line write) 17 */ 18 19 fprintf(fp, " %c,%c,%c,%c,%c\n " ,money,a ,b,b,day); // Use fprintf to change the output port to document 20 fclose(fp); // Close the specified file 21 22 return 0 ; 23 }
Welcome to reference