C solution (Marius Gavrilescu)
We can iterate over each character in the format string. If s[i] is %, we call scanf with s[i]s[i+1] and the next offset. Otherwise, we call scanf with s[i].1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 char s[205], f[3]; 6 unsigned char mem[128]; 7 8 int main(void){ 9 fgets(s, sizeof s, stdin); 10 strtok(s, ","); 11 12 for(int i = 0; s[i] ; i++) 13 if((*f = s[i]) == '%') 14 f[1] = s[++i], scanf(f, mem + atoi(strtok(NULL, ","))); 15 else 16 f[1] = 0, scanf(f); 17 18 for(int i = 0 ; i < 128 ; i++) 19 printf("%02X", mem[i]); 20 }