#include <iostream>
using namespace std;
#include <stdio.h>
#include <inttypes.h>
int main()
{
char format[] = "%*[^,], HEX_DATA:%4" SCNx16 ", NEGATIVE_VAL:%" SCNd8;
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: %04" PRIx16 ", NEGATIVE_VAL: %" PRId8, status, hex_data, neg_val);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxpbnR0eXBlcy5oPgoKaW50IG1haW4oKQp7CiAgICBjaGFyIGZvcm1hdFtdID0gIiUqW14sXSwgSEVYX0RBVEE6JTQiIFNDTngxNiAiLCBORUdBVElWRV9WQUw6JSIgU0NOZDg7CiAgICBjaGFyIHN0cltdID0gInRleHRfdG9fYmVfc2tpcHBlZCwgSEVYX0RBVEE6ZDgwMCwgTkVHQVRJVkVfVkFMOi0yMCI7CgogICAgdWludDE2X3QgaGV4X2RhdGEgPSAwOwogICAgaW50OF90IG5lZ192YWwgPSAwOwoKICAgIGludCBzdGF0dXMgPSBzc2NhbmYoc3RyLCBmb3JtYXQsICZoZXhfZGF0YSwgJm5lZ192YWwpOwoKICAgIHByaW50ZigiU3RhdHVzOiAlZCwgSEVYX0RBVEE6ICUwNCIgUFJJeDE2ICIsIE5FR0FUSVZFX1ZBTDogJSIgUFJJZDgsIHN0YXR1cywgaGV4X2RhdGEsIG5lZ192YWwpOwoKICAgIHJldHVybiAwOwp9