level 1
c语言怎么写入txt文件10.0
每次都是10没有小数点
2021年02月18日 12点02分
1
level 1
#include <stdio.h>
#include <string.h>
int main()
{
FILE* fp;
char buf[32];
fp = fopen("test.txt","w+");
int a= 10;
sprintf(buf, "%.1f\n", (float)a);
fwrite(buf, strlen(buf), 1, fp);
fclose(fp);
return 0;
}
2021年03月02日 01点03分
12