Thanks for the reply.
Looking at your example though... you seem to pre-define the number of elements in your array:
char scientists[4][10]
ie: [4]
But there is no way to know this before hand..
it is acceptable to just use a value that is over the threshold?
ie:
char scientists[10][10]
And when adding do I just do:
scientists[x] = (parsed, comma delimited chunk)
Thinking that there will NOT be more than '10 steps' containing more than '10 characters'?.. even if one command comes in with only say 2 actions of less characters each? As long as I dont go BEYOND that declared limit.. I'm fine?
Lastly.. how do I handle 'clean up' then?
How do I clear out my
char scientists[10][10]
array? So it can accept a newly parsed incoming serial line?
And how do I access that then? As simple as:
scientists[x]
??
to get the intended index?
@groundFungus
I'm not sure what part of the #5 examples is shedding light on my question I guess? (maybe I dont understand it properly?)
I see the parseData() function.
void parseData() { // split the data into its parts
char * strtokIndx; // this is used by strtok() as an index
strtokIndx = strtok(tempChars,","); // get the first part - the string
strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC
strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
integerFromPC = atoi(strtokIndx); // convert this part to an integer
strtokIndx = strtok(NULL, ",");
floatFromPC = atof(strtokIndx); // convert this part to a float
}
It looks like you have to KNOW how many delimited chunks there will be? (not acceptable in this scenario)
I'm guessing this line is the focus:
strtokIndx = strtok(tempChars,","); // get the first part - the string
strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC
but I dont really understand strok(32, ","); line? WHere is the tempChars/32 value coming into play here? (why?)
And then copies it into the:
char messageFromPC[numChars] = {0};
char array?
Why doesnt this have to be a multi-dimensional array?
Thanks!
*Update: not sure why all the code snippets have so much extra space after them? Cant seem to delete it.