Parsing serial dats

I have been trying to parse a stream of serial data that looks like this (i think it is spaced by tabs). I want to end up with an array of floats.

-1.1251 41.29 -0.03 0.00 0.0000 0.0 0.0 0 0.0 0.00 0.99 0.00 0.00 1

-1.1251 41.29 -0.03 0.00 0.0000 0.0 0.0 0 0.0 0.00 0.99 0.00 0.00 1

-1.1251 41.29 -0.03 0.00 0.0000 0.0 0.0 0 0.0 0.00 0.99 0.00 0.00 1

-1.1251 41.28 -0.03 0.00 0.0000 0.0 0.0 0 0.0 0.00 0.99 0.00 0.00 1

I have tried a few different approaches but I am not getting it to work. I made a loop that seems like it should do the job but it just does weird things to my code. please help.

void convertToFloatArray() {
if (newData == true) {
int p = 0;
int j = 0;
int k = 0;
char tokenPtr[] = {0};
float tokenFlPtr;

while( i <= 68 ) {
if (receivedChars[p] == ' '){
tokenFlPtr = atof(tokenPtr);
floatOutput[k] = tokenFlPtr;
p++;
j = 0;
k++;
}

else {
tokenPtr[j] = receivedChars[p];
p++;
j++;
}
}
}
}

The parse example in Serial Input Basics may give you some ideas.

...R

'\t' is the tab character. '\n' is the newline character. You may also see other characters such as carriage-return. Only accept characters you recognize and ignore all others.

tokenPtr[j]

How big can j get? How much storage did you allocate to tokenPtr? You are writing on memory you don't own.

Robin

thank you I did read the Serial basics but couldn't get the example to work until...

MorganS

I used '\t' and that changed everything so thank you both