I have a trouble with NMEA data(gpzda). The problem is explained below.
NMEA Data : $GPZDA,011856.00,17,03,2018,,*61
My Parsing Code.
char hour[2] = { 0 };
for (int i=0; i < 2; i++) hour[i] = utctime[i];
info.tm_hour = atoi(hour);
char min[2] = { 0 };
for (int i=0; i < 2; i++) min[i] = utctime[i + 2];
info.tm_min = atoi(min);
char sec[2] = { 0 };
for (int i=0; i < 2; i++) sec[i] = utctime[i + 4];
info.tm_sec = atoi(sec);
cout << info.tm_year << " | " << info.tm_mon << " | " << info.tm_mday << " | " << info.tm_hour << " | " << info.tm_min << " | " << info.tm_sec << endl;
The code is well working, but some time the hour value is strange like a "126". I thought that "6" is add from another memory. How to parse this data to well work?