#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main() {
const char* filename = "d:\\data.txt";
FILE* fp = fopen(filename, "r");
if (fp == NULL) {
fprintf(stderr, "Error open file");
exit(1);
}
float f1, f2, f3, f4 = 0.0f;
fscanf(fp, "%f %f %f %f", &f1, &f2, &f3, &f4);
printf("%f %f %f %f\n", f1, f2, f3, f4);
printf("%.7f %.7f %.7f %.7f\n", f1, f2, f3, f4);
printf("%.4f %.4f %.4f %.4f\n", f1, f2, f3, f4);
printf("%.2f %.2f %.2f %.2f\n", f1, f2, f3, f4);
return 0;
}
// data.txt -> 3.14 8.769 35.2 928.6237
/*
run
3.140000 8.769000 35.200001 928.623718
3.1400001 8.7690001 35.2000008 928.6237183
3.1400 8.7690 35.2000 928.6237
3.14 8.77 35.20 928.62
*/