-
Notifications
You must be signed in to change notification settings - Fork 918
Closed
Description
Thanks for writing such a neat piece of software!
I was struggeling a little bit with examples/simple.c, trying to get started. After fiddling around for a bit, I got the snippet below to work. I thought might be useful to include among the other examples.
#include <msgpack.h>
#include <stdio.h>
static inline int my_callback(void* data, const char* buf, unsigned int len)
{
// print buffer in hex
for(int i = 0 ; i < len ; i++)
printf("%02x ", 0xFF & buf[i]);
printf("\n");
}
int main()
{
msgpack_packer pk;
msgpack_packer_init(&pk, 0, my_callback);
msgpack_pack_int(&pk, 13);
msgpack_pack_float(&pk, 0.1);
msgpack_pack_map(&pk, 1);
msgpack_pack_int(&pk, 9);
msgpack_pack_false(&pk);
return 0;
}Metadata
Metadata
Assignees
Labels
No labels