i'm sending strings to another computer via the serial port as I'm developing an interface between two computers (one is going to be used onboard an RC helicopter to control it, although its just going to datalog at the moment).
currently, i'm doing this... :
rc = sscanf(controlword, "%c, %d, %d", &type, &var_1, &var_2);
and then testing rc firstly to see if it is 1 or 3, and then type so i can tell it what to do. This works fine for single word entries such as quit... rc=1 and type = q || Q and i don't have to worry about var_1 or var_2.
If i want to send something with parameters (for example "servo, 1, 255") then for it to be able to get the %d's i have to send it S,1,255.
I noticed in my copy of kernighan and ritchie that i can use [...] in my sscanf argument type....
matches the longest non-empty string of input characters from the set between the brackets; char *. A '\0' is added. ...] includes ] in the set.
but i'm unsure how to use it or whether or not i can specify a string inside the parenthesis. Hopefully this shouldn't be a challenge to all you veterans out there!