VC读取txt文件数据问题

wjl20060620 wjl20060620 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
txt文件
1 1.001 0
2 2.001 0
3 2.998 0
4 3.999 0
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *fp1;
double x1=0,y1=0,x1_x1=0,x1_y1=0;
int n;
int i;
printf("input n\n");
scanf("%d",&n);
struct point_type
{
double x;
double y;
double z;
};
struct point_type point[3000];
if((fp1=fopen("zhixian.txt","r"))==NULL)
{
printf("cant not open file");
exit(1);
}

for(i=0;i<n;i++)
{
fscanf(fp1,"%lf %lf",point[i],&point[i].x,&point[i].y);
x1+=point[i].x;
y1+=point[i].y;
x1_y1+=point[i].x*point[i].y;
x1_x1+=point[i].x*point[i].x;
}
fclose(fp1);
}
为什么不能运行?
...全文
评论 4
收藏 已收藏
分享
返回顶部
wjl20060620
VC/MFC 16,550 成员 421,605 内容