First collect all of the characters up to the new-line (`\n' or line-feed) into an array of characters, and put a zero byte after the last one.
Since It looks like all of the strings you need to parse consist of one a single letter followed by the value you want, value = atoi(inputArray[1];
will return the value as a 16-bit int. If it could be larger than 32767 but less than 65536 (probably not if you're driving a servo with it), then cast the value to unsigned.
If there might be an unknown number of characters (non-digits) preceeding the value, the C function size_t strcspn(const char *string, const char *cset)
will return the length of the leading sub-string of string
that does not contain characters in cset
. So value = atoi(inputArray[strcspn(inputArray, "0123456789")]);
will do the same thing, but calculating the array index of the first digit in the string.
(For completeness, note there is a companion function, size_t strspn(const char *str, const char *cset);
, that returns the leading sub-string of 'string' consisting only of characters in cset
).