读取文件链接: https://pan.baidu.com/s/1q1y_4be_HiRdnoWsEdsXIA?pwd=0000 提取码: 0000
利用文件读取发现无法读取,不知道是不是e-1什么的没读取进去的原因
文件读取格式如图所示
#include <math.h>
#include<fstream>
using namespace std;
#define PI 3.1415926535897932384626433832795
xl dq[200];
CString openpath;
bool flag0;
struct xl //星历
{
char gps[10];//存储PRN和历元
int year;
int month;
int day;
int hour;
int minute;
int second;
double ClkBias;//偏差
double ClkDrift;//漂移
double ClkDriftRate;//漂移速度
double IODE;
double Crs;
double DetlaN;
double M0;
double Cuc;
double e;
double Cus;
double SqrtA;
double TOE;
double Cic;
double Omega;
double Cis;
double i0;
double Crc;
double omega;
double OmegaDot;
double iDot;
double codesOnL2Channel;
double GPSWeek;
double L2PDataFlag;
double SVAccuracy;
double SVHealth;
double TGD;
double IODC;
double TransTimeOfMsg;
double Spare1;
double Spare2;
double Spare3;
};
void C星历文件View::readfile()
{
CString filter(_T("17n文件|*.17n||ALL FILES||*.*|"));
CFileDialog dlg(true, NULL, NULL, NULL, filter, this);
if (dlg.DoModal() != IDOK)
{
MessageBox(_T("文件未打开"), _T("警告!"), MB_ICONWARNING);
flag0 = false;
return;
}
else
{
openpath = dlg.GetPathName();
MessageBox(_T("打开文件成功"), _T("提示!"), MB_ICONWARNING);
flag0 = true;
}
int i, j;
char line[60];
char line2[300];
ifstream fp(openpath);
for (i = 0; i < 7; i++)
{
fp.getline(line, 60, '\n');
}
for (i = 0;; i++)
{
fp.getline(line2, 300, '\n');
for (j = 0; j < 300; j++)
{
if (line2[j] == 'D')
line2[j] = 'e';
}
sscanf_s(line2, "%s %d %d %d %d %d %d %lf %lf %lf", dq[i].gps, _countof(dq[i].gps), &dq[i].year, &dq[i].month, &dq[i].day, &dq[i].hour, &dq[i].minute, &dq[i].second, &dq[i].ClkBias, &dq[i].ClkDrift, &dq[i].ClkDriftRate);//无法读取
fp.getline(line2, 300, '\n');
for (j = 0; j < 300; j++)
{
if (line2[j] == 'D')
line2[j] = 'e';
}
sscanf_s(line2, "%lf %lf %lf %lf", &dq[i].IODE, &dq[i].Crs, &dq[i].DetlaN, &dq[i].M0);//无法读取
}
}