jobo said:
Hello,
If I'm given a string that always starts with the word "free" followed
by an integer ("free xx"). How do I parse through the characters and
get to the integer value? Thanks.
Is there always a space between "free" and the integer?
Do you know for certain that there will be no characters after the
integer?
If so, then if the string is provided as a char * called (e.g.) "str"
then the integer (as a string) will be at str+5 and you could use one
of the standard functions (from the manual) to convert it to an integer
or long datatype.
There are other approaches, for example there is a function (also in
the manual) for scanning strings and extracting data from them. Or you
could write a routine that searches through the string till it find the
first digit, and then continues, multiplying a running total by 10 (I
presume the integer is in decimal representation) and adding the value
of the next digit, till you run out of digits.