class EarthQuakeRecord { private: static const int nYEAR=0, nMONTH=5, nDAY=8, nHOUR=11, nMINUTE=14, nSECOND=17, nUTC=22; int nYear, nMonth, nDay, nHour, nMinute, nSecond; static const int nLATITUDE=31, nLONGITUDE=38, nMAGNITUDE=45; double dLatitude, dLongitude, dMagnitude; static const int nDEPTH=50, nEPICENTRE=55; int nDepth, nEpicentre; static const int nCITYLATITUDE=64, nCITYLONGITUDE=72; double dCityLatitude, dCityLongitude; static const int nSTATEPROVINCE=87; int nStateProvince; static const int nCITYNAME=93, nDATASOURCE=125; string sCityName; public: EarthQuakeRecord() { } void ParseInput(char* pszRawRecord) { pszRawRecord[nMONTH-1] = '\0'; pszRawRecord[nDAY-1] = '\0'; pszRawRecord[nHOUR-1] = '\0'; pszRawRecord[nMINUTE-1] = '\0'; pszRawRecord[nSECOND-1] = '\0'; pszRawRecord[nLATITUDE-1] = '\0'; pszRawRecord[nLONGITUDE-1] = '\0'; pszRawRecord[nMAGNITUDE-1] = '\0'; pszRawRecord[nDEPTH-1] = '\0'; pszRawRecord[nEPICENTRE-1] = '\0'; pszRawRecord[nCITYLATITUDE-1] = '\0'; pszRawRecord[nCITYLONGITUDE-1] = '\0'; pszRawRecord[nSTATEPROVINCE-1] = '\0'; nYear = atoi(pszRawRecord); nMonth = atoi(pszRawRecord+nMONTH); nDay = atoi(pszRawRecord+nDAY); nHour = atoi(pszRawRecord+nHOUR); nMinute = atoi(pszRawRecord+nMINUTE); nSecond = atoi(pszRawRecord+nSECOND); dLatitude = atof(pszRawRecord+nLATITUDE); dLongitude = atof(pszRawRecord+nLONGITUDE); dMagnitude = atof(pszRawRecord+nMAGNITUDE); nDepth = atoi(pszRawRecord+nDEPTH); dCityLatitude = atof(pszRawRecord+nCITYLATITUDE); dCityLongitude = atof(pszRawRecord+nCITYLONGITUDE); nStateProvince = atoi(pszRawRecord+nSTATEPROVINCE); char* pcStartOfCityString = pszRawRecord+nCITYNAME; char* pcEndOfCityString = pszRawRecord+(nDATASOURCE-1); while (pcEndOfCityString > pcStartOfCityString && *pcEndOfCityString == ' ') pcEndOfCityString--; *(pcEndOfCityString+1) = '\0'; sCityName = pcStartOfCityString; } void Display() { cout << nYear << setw(3) << nMonth << setw(3) << nDay << setw(5) << dMagnitude << setw(5) << nDepth << " " << sCityName << endl; } };