Use this:
const char *str = "AGE:83";
int age;
sscanf(str, "%*[^0-9]%d", &age);
This format skips any digits and parses the integer after that.
Please note that it will not work if there are no digits in front of the number. To handle the case where a number may be at the beginning of a line, first try a direct match:
if (sscanf(str, "%d", &age) != 1
&& sscanf(str, "%*[^0-9]%d", &age) != 1) {
return 1;
}
, , '-' ( "%*[^0-9-]%d")
atoi() strtol():
age = atoi(str + strcspn(str, "0123456789"));
, , , AGE:, :
age = atoi(str + 4);
undefined, 4 , .