1. #include <stdio.h>
    2. /**
    3. * @brief 文件操作,将参数写入到文件中
    4. * @param write data_1 data_2 data_3
    5. * @param filename file's path and name
    6. * @retval None
    7. */
    8. void WriteIn_Params(double data_1,double data_2,double data_3,char* filename)
    9. {
    10. //file point
    11. FILE *fp;
    12. //get file operate error handle
    13. int nResult;
    14. fp = fopen(filename, "a+"); //新建文本文件并追加数据
    15. if (NULL == fp)
    16. {
    17. printf("Open file error\n");
    18. }
    19. //write in
    20. nResult = fprintf(fp, "%f %f %f\n", data_1,data_2,data_3);
    21. //Write data failed
    22. if (nResult < 0)
    23. {
    24. printf("Write data to file error\n");
    25. }
    26. printf("Write formatted data to file completely\n");
    27. //close the file and delet the point
    28. fclose(fp);
    29. }