Im working with NMEA sentences and am having trouble parsing them. The NMEA sentence is delimited by commas. So, I have to parse this line and store the data inbetween the commas.
The problem is I am using a program called wiz-c to do this and it does not have methods normally made available in C++.
So I have came up with this bit of code
I have to do this 10-15 times and record the data in each field.
skipComma(1); // skips the first comma
ch=WaitRx(); // reads data into a temp ch variable
if(ch!=',') // if ch does not equal comma then
data=ch; // Store ch in variable called data
data='' // If ch does equal comma then set data to nothing
This doesnt seem to work, anyone got any ideas?
You only store a single character, store an entire string instead. Read characters until a comma is found, then store the entire string you got so far and start over. Repeat until EOF (end of file) is found.
(the functions above are pseudo-like, use whatever functions exists on your system)
list all_words = EmptyList();
string current_word = "";
char current_char = GetChar();
if(current_char == ',')
current_word = "";
current_word += current_char;