I am trying to split my actual key on dot and then extract all the fields from after splitting it on dot.
My key would look like something this -
@event.1384393612958.1136580077.TESTING
Currently, I am able to extract only the first field which is @event
after splitting it on the dot. Now how to extract all the other fields as well. Below is my code, I am using currently to extract the first field from it.
if (key)
{
char* first_dot = strchr(key, '.');
if (first_dot)
{
// cut at the first '.' character
first_dot[0] = 0;
}
}
cout << "Fist Key: " << key << endl;
And then after extracting individual fields, store the second field as uint64_t
, third field as uint32_t
and last field as string
.
Update:-
This is what I have got now -
if (key)
{
char *first_dot = strtok(key, ".");
char *next_dot = strtok(NULL, ".");
uint64_t secondField = strtoul(next_dot, 0, 10);
cout << first_dot << endl;
cout << secondField << endl;
}
From which I am able to extract first and second field. What about third and fourth field?