#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
char format[] = "%*s HEX_DATA:%4hx, NEGATIVE_VAL:%hhd";
char str[] = "text to be skipped, HEX_DATA:d800, NEGATIVE_VAL:-20";
uint16_t hex_data = 0;
int8_t neg_val = 0;
int status = sscanf(str, format, &hex_data, &neg_val);
printf("Status: %d, HEX_DATA: %04x, NEGATIVE_VAL: %d", status, hex_data, neg_val);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpCnsKICAgIGNoYXIgZm9ybWF0W10gPSAiJSpzIEhFWF9EQVRBOiU0aHgsIE5FR0FUSVZFX1ZBTDolaGhkIjsKICAgIGNoYXIgc3RyW10gPSAidGV4dCB0byBiZSBza2lwcGVkLCBIRVhfREFUQTpkODAwLCBORUdBVElWRV9WQUw6LTIwIjsKCiAgICB1aW50MTZfdCBoZXhfZGF0YSA9IDA7CiAgICBpbnQ4X3QgbmVnX3ZhbCA9IDA7CgogICAgaW50IHN0YXR1cyA9IHNzY2FuZihzdHIsIGZvcm1hdCwgJmhleF9kYXRhLCAmbmVnX3ZhbCk7CgogICAgcHJpbnRmKCJTdGF0dXM6ICVkLCBIRVhfREFUQTogJTA0eCwgTkVHQVRJVkVfVkFMOiAlZCIsIHN0YXR1cywgaGV4X2RhdGEsIG5lZ192YWwpOwoKICAgIHJldHVybiAwOwp9