📜  在文件 C 中写入变量 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:13.550000             🧑  作者: Mango

代码示例1
FILE* f = fopen("number.txt", "w");  // open the file for writing
 if (f != NULL)                       // check for success
 {
     fprintf(f, "%d", 42);            // write the number 42 as a string
     fclose(f);                       // close the file
     f = NULL;                        // set file handle to null since f is no longer valid
 }