GPS定位中n文件读取

这是读取n文件的中间代码,比较优秀。 

for (int j=1;j<8;j++)      //这个循环用的绝壁优秀
	{
		getline(fin,str);
		switch(j)
		{

		case 1: 
			NAVREC[numofi].dIODE		=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dCrs		=atof(str.substr(22,19).c_str());
			NAVREC[numofi].dDetlaN		=atof(str.substr(41,19).c_str());
			AVREC[numofi].dM0		=atof(str.substr(60,19).c_str());			break;			
		case 2:
			NAVREC[numofi].dCuc		=atof(str.substr(3,19).c_str());
			NAVREC[numofi].d_e		=atof(str.substr(22,19).c_str());
			NAVREC[numofi].dCus		=atof(str.substr(41,19).c_str());
			NAVREC[numofi].dSqurtA		=atof(str.substr(60,19).c_str());	                break;	
		case 3:
			NAVREC[numofi].dTOE		=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dCic		=atof(str.substr(22,19).c_str());
			NAVREC[numofi].dOmega		=atof(str.substr(41,19).c_str());
			NAVREC[numofi].dCis		=atof(str.substr(60,19).c_str());	                break;	
		case 4:	
			NAVREC[numofi].d_i0		=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dCrc		=atof(str.substr(22,19).c_str());
			NAVREC[numofi].d_omega		=atof(str.substr(41,19).c_str());
			NAVREC[numofi].dOmegaDot	=atof(str.substr(60,19).c_str());
                        break;	
		case 5:
			NAVREC[numofi].d_iDot		=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dCodesOnL2Channel=atof(str.substr(22,19).c_str());
			NAVREC[numofi].dGPSWeek		=atof(str.substr(41,19).c_str());
			NAVREC[numofi].dL2PDateFlag	=atof(str.substr(60,19).c_str());
                        break;	    
		case 6:
			NAVREC[numofi].dSVAccuracy	=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dSVHealth	=atof(str.substr(22,19).c_str());
			NAVREC[numofi].dTGD		=atof(str.substr(41,19).c_str());
			NAVREC[numofi].dIODC		=atof(str.substr(60,19).c_str());
                        break;	
		case 7:
			NAVREC[numofi].dTransmissionTimeOfMessage=atof(str.substr(3,19).c_str());
			NAVREC[numofi].dFitInterval	=atof(str.substr(22,19).c_str());
//			NAVREC.dSpare1		        =atof(str.substr(41,19).c_str());
//			NAVREC.dSpare2		        =atof(str.substr(60,19).c_str());
                        break;	
               default:
                        printf("error\n");
                        break;

}	

 

你可能感兴趣的:(C++)