Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Created December 16, 2016 09:25
Show Gist options
  • Save tetkuz/f45e9fe26e9da84509db70631b14e2da to your computer and use it in GitHub Desktop.
Save tetkuz/f45e9fe26e9da84509db70631b14e2da to your computer and use it in GitHub Desktop.
GByteArray sample
#include <string.h>
#include <glib.h>
int main()
{
gchar *string = "message";
GByteArray *array;
guint8 *p;
array = g_byte_array_new ();
array = g_byte_array_append (array, (guint8 *)string, strlen(string));
p = g_byte_array_free (array, FALSE);
g_print ("%s\n", p);
g_free (p);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment