我正在尝试从文本文件中读取数字并将其存储到数组中.当我尝试读取数组中的数字时,输出略微偏离.这是我的代码:
struct point{
double x[7];
double y[7];
}point;
int main()
{
FILE *fp;
fp = fopen("data_2.txt", "r");
struct point points;
int len = 8;
int i = 0;
int j = 0;
int k = 0;
double a = 0;
double b = 0;
double c = 0;
double total = 0;
int left=0;
int right=0;
int line = 0;
for (i=0;i<len;i++)
{
fscanf(fp, "%lf %lf", &points.x[i],&points.y[i]);
}
for(i = 0; i < len;i++)
printf("looking at point %.2f %.2f\n",points.x[i],points.y[i]);
return(0); …Run Code Online (Sandbox Code Playgroud)