#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
char format[] = "%*[^,], 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+CgppbnQgbWFpbigpCnsKICAgIGNoYXIgZm9ybWF0W10gPSAiJSpbXixdLCBIRVhfREFUQTolNGh4LCBORUdBVElWRV9WQUw6JWhoZCI7CiAgICBjaGFyIHN0cltdID0gInRleHRfdG9fYmVfc2tpcHBlZCwgSEVYX0RBVEE6ZDgwMCwgTkVHQVRJVkVfVkFMOi0yMCI7CgogICAgdWludDE2X3QgaGV4X2RhdGEgPSAwOwogICAgaW50OF90IG5lZ192YWwgPSAwOwoKICAgIGludCBzdGF0dXMgPSBzc2NhbmYoc3RyLCBmb3JtYXQsICZoZXhfZGF0YSwgJm5lZ192YWwpOwoKICAgIHByaW50ZigiU3RhdHVzOiAlZCwgSEVYX0RBVEE6ICUwNHgsIE5FR0FUSVZFX1ZBTDogJWQiLCBzdGF0dXMsIGhleF9kYXRhLCBuZWdfdmFsKTsKCiAgICByZXR1cm4gMDsKfQ==