error C2059: syntax error : '}'的问题
#include<stdlib.h>#include<stdio.h>
#include<math.h>
#include"dist.h"
#include"v_quatization.h"
#include"spa.h"
#define Nagent 146
#define Nanchor 6
/*已知坐标的节点位置*/
//const struct position anchor[Nanchor]={{100,100},{100,200},{100,300},{300,100},{300,200},{300,300}};
/**基站位置固定在中心*/
//const double b_x=200;
//const double b_y=200;
void main()
{
int i,s;
FILE *fp0,*fp;
double d_agent[Nagent],toa[Nagent],alpha[Nagent];
struct position *agent_pos,agent[Nagent];
double err=0;
agent_pos=0;
/*打开文件,以准备更新矢量量化所需的各个样值*/
/*读取需要定位的点的真实位置和测量距离测量时间*/
fp=fopen("C:\\agent_pos.txt","r");
if(fp==NULL)
{
printf("cannot opent the file \n");
exit(0);
}
for(i=0;i<Nagent;i++)
{
fscanf(fp,"%lf,%lf,%lf,%lf\n",&agent[i].x,&agent[i].y,&d_agent[i],&toa[i]);
alpha[i]=atan(fabs((agent[i].x-b_x)/(agent[i].y-b_y)));
}
agent_pos=spa(d_agent,toa,alpha);
fp0=fopen("C:\\w_samp.txt","w");
if(fp0==NULL)
{
printf("cannot opent the file \n");
exit(0);
}
for(i=0;i<Nagent;i++)
{
fprintf(fp0,"%lf,%lf,%lf,%lf\n",(agent_pos+i)->x,(agent_pos+i)->y,d_agent[i],toa[i]);
//err=dist((*(agent_pos+i)).x,(*(agent_pos+i)).y),&agent[i].x,agent[i].y))*dist((*(agent_pos+i)).x,(*(agent_pos+i)).y),&agent[i].x,agent[i].y));
}
/*计算误差,并更新w_samp.txt*/
/* for(i=0;i<Nagent;i++)
{
err+=dist((agent_pos+i)->x,(agent_pos+i)->y),agent[i].x,agent[i].y))*dist((agent_pos+i)->x,(agent_pos+i)->y),agent[i].x,agent[i].y));
}
//rewind(fp0);
err/=Nagent;
printf("the error of location is: %lf \n",err);*/
fclose(fp);
fclose(fp0);
}// 出现error C2059: syntax error : '}'
为什么呢,去掉这个大括号就没有这个问题,但明显不对啊。
co_location.rar
(109.38 KB)
附件是整个工程,请大牛们帮忙看看哈,不胜感激
[ 本帖最后由 蓝夕 于 2010-10-17 18:44 编辑 ]