const char* cookie_format = "uid=%zu-%s"; // sscanf into uid=size_t and hmac (in hex)
size_t uid;
char hmac[40];
auto scan_count = sscanf(cookie.c_str(), cookie_format, &uid, &hmac);
char hmac[40];
auto scan_count = sscanf(cookie.c_str(), cookie_format, &uid, &hmac);
На входных данных:
uid=20364-726552704a0366dc3e0ca627e6ebacdeb8ecff70
получаем следующее:
uid=20224 hmac=726552704a0366dc3e0ca627e6ebacdeb8ecff70
size_t uid;
char hmac[41] = "";
sscanf("uid=20364-726552704a0366dc3e0ca627e6ebacdeb8ecff70", "uid=%zu-%s", &uid, &hmac[0]);
printf("%zu-%s\n", uid, hmac);