This commit is contained in:
james 2024-07-31 09:41:30 +08:00
parent 062d483880
commit 3ab862f16f
1 changed files with 2 additions and 1 deletions

View File

@ -106,8 +106,9 @@ void make_file()
//文件描述符 //文件描述符
int fd; int fd;
// String = "Hello, RT-Thread.Welcom to RSOC!\n temp: 123, humi: 789"; // String = "Hello, RT-Thread.Welcom to RSOC!\n temp: 123, humi: 789";
//用只写方式打开文件,如果没有该文件,则创建一个文件 //用只写方式打开文件,如果没有该文件,则创建一个文件
fd = open("/fal/test/Data.txt", O_APPEND | O_CREAT); fd = open("/fal/test/Data.txt", O_WRONLY | O_CREAT | O_APPEND,0); //和原来相比只是把O_TRUNC参数更改为O_APPEND即更改为打开后如果再进行写入将从文件的末尾位置开始写。
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,String); // rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,String);
//如果打开成功 //如果打开成功
if (fd >= 0) if (fd >= 0)