| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5036 人关注过本帖
标题:error C2059: syntax error : '}'的问题
只看楼主 加入收藏
蓝夕
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-15
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:6 
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 编辑 ]
搜索更多相关主题的帖子: syntax 
2010-10-17 17:19
m21wo
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:4
帖 子:440
专家分:1905
注 册:2010-9-23
收藏
得分:10 
#include"dist.h"
#include"v_quatization.h"
#include"spa.h"

这几个文件都没有,无从改起

If You Want Something, Go Get It, Period.
2010-10-17 17:35
蓝夕
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-15
收藏
得分:0 
回复 2楼 m21wo
《dist.h》
#ifndef PRO0
#define PRO0 1
double dist(double,double,double,double);
#endif

<spa.h>
#ifndef PRO3
#define PRO3 1
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#include"dist.h"
#define R 50
#define D 50
#define Iter 4
#define PI 3.14
#define Nagent 146
#define Nanchor 6
#define NumC 96
struct position{
    double x;
    double y;
};

struct position* spa(double [],double[],double []);

#endif

<v_quantization.h>
#ifndef PRO2
#define PRO2 1
#define Radius 200
#define S 1.732
#define NumS 1536

struct table{
    double x;
    double y;
    double d;
    double toa;
};

struct table * v_q();
struct table table0,*p;
#endif
上面三个文件编译都没有问题了
2010-10-17 18:26
蓝夕
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-15
收藏
得分:0 
大牛们帮帮忙啊
2010-10-17 21:08
m21wo
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:4
帖 子:440
专家分:1905
注 册:2010-9-23
收藏
得分:0 
spa(d_agent,toa,alpha) 函数没写!

#include"v_quatization.h"
与你命名<v_quantization.h>
不一致!
先写完整再说!

If You Want Something, Go Get It, Period.
2010-10-17 21:15
蓝夕
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-15
收藏
得分:0 
回复 5楼 m21wo
完整的程序在附件里,麻烦你看一下,谢谢啦
2010-10-17 21:31
蓝夕
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-15
收藏
得分:0 
已解决,原来是注释部分多了个*造成的。
2010-10-18 10:58
快速回复:error C2059: syntax error : '}'的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020604 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved