#define UNKNOWN_CONTROL -1 // integer to recognize unknown pairs
#define CONSTANT_STRING_LENGTH 18 // The string length
int i;
char string[CONSTANT_STRING_LENGTH]; // This is your string
int pairs[CONSTANT_STRING_LENGTH/2]; // Array to store results
for (i=0; i<CONSTANT_STRING_LENGTH/2; i++) { // For each pair in the string
if (string[i*2] == '?' || string[i*2]+1 == '?') // Is it a '??' pair?
pairs[i] = UNKNOWN_CONTROL; // Store some constant (> 99)
else
pairs[i] = string[i*2] * 10 + string[i*2+1] - '0' * 11; // Compute the number and store
}
And then your array pairs would be filled with your desired results if I got your question right.
EDIT: To understand the computing bit, you've got to understand that ASCII characters (printable, the ones you store on strings) don't correspond to their integer counterparts. ASCII '0' is integer 48, ASCII '1' is integer 49, ASCII '2' is integer 50, and forth...
By multiplying the first character by ten and adding the first characters, you're summing the ASCII values, not the integer ones, so you've got to subtract the bias. Substracting '0' (the base number for ASCII) would work for one character (e.g. ASCII '2' - ASCII '0' == 2), but you've got to multiply it by 11 for two characters.
Keep in mind '0' * 11 is the same as '0' * 10 + '0'. Doing some redistribution of the math you can see exactly what's being done there:
pairs[i] = (string[i*2] - '0') * 10 + string[i*2+1] - '0';
"?123?456?789?12345"and if so, what two integers do you intend to extract from it? Oh, and do you mean "two (character chunks)", or two-character chunks? If the latter then I wouldn't necessarily bother with atoi, you can convert a pair of digits to an integer withstr[0] * 10 + str[1] - '0' * 11. Furthermore, if "?4" is a possible two-character chunk then atoi can't convert it anyway, so you aren't necessarily saving any special-casing by using it.010to parse as decimal (10) or octal (8)?