typedef struct
{
int dprogtic;
int dtic;
double tr;
double dt;
int mflag;
short sv;
short codephase;
unsigned short codedcophase;
unsigned short carrierdcophase;
short ms;
short bit;
int carriercycle;
int s;
}CHxMEAS;
typedef struct
{
int dprogtic;
int dtic;
double tr;
double dt;
CHxMEAS m[14];
}MEAS;
MEAS jz_data_meas;
然后读取txt文本
if((fpC=fopen(“measA.txt”,”r+”) )==NULL)
{
printf(“The file <measA*.txt> can not be opened.\n”);
exit(1);
}
fscanf(fpC,”%d %d %d %f\n”,&jz_data_meas.dprogtic,&jz_data_meas.dtic,&jz_data_meas.tr,&jz_data_meas.dt);
for(i=0;i<14;i++)
{
fscanf(fpC,”%2d%2d%4d%4u%4u%4%4d%4d%6d”,&jz_data_meas.m[i].mflag, &jz_data_meas.m[i].sv, &jz_data_meas.m[i].codephase, &jz_data_meas.m[i].codedcophase&jz_data_meas.m[i].carrierdcophase,&jz_data_meas.m[i].ms, &jz_data_meas.m[i].bit, &jz_data_meas.m[i].carriercycle, &jz_data_meas.m[i].s);
}
文本里的数据按结构体为单元存储的,如下
0 0 116183 0.000000000000000
1 1 1052 4956 56009 5 20 4092169 116183
1 2 244 59050 61601 1 20 4092149 116183
1 3 533 23284 50958 6 20 4092184 116183
1 4 1855 30474 37189 1 20 4092166 116183
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
1 30 843 47619 50997 2 27 4090314 375966
1 8 1918 40327 48850 0 20 4093869 116183
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 116184 0.000000000000000
1 1 1052 24807 2387 5 20 4092189 116184
1 2 245 6896 49377 1 20 4092168 116184
1 3 533 41575 24612 6 20 4092203 116184
1 4 1855 42343 37049 1 20 4092185 116184
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
1 30 841 31546 15620 2 27 4090333 375967
1 8 1921 7397 54574 0 20 4093887 116184
0 0 0 0 0 0 0 4092000 0
0 0 0 0 0 0 0 4092000 0
第一组数据输出一个成了随机变量,不是读入的数据,第二组索性无法读入,大神帮忙支招一下