我有一个要解码的 base 64 编码字符串。 它看起来像这样:
VGhpcyBpcyBhIGZpbGUgdGhhdCBJIHdhbnQgdG8gZGVjb2Rl
当我这样做的时候..
gsize *out_len;
unsigned const char *decoded;
decoded = g_base_64_decode(myString, out_len);
并打印出我的解码字符串,我也得到 NULL,我得到断言: 'out_len != NULL' 从 Glib 失败
为什么会这样?如何使用此函数正确解码我的字符串? https://developer.gnome.org/glib/stable/glib-Base64-Encoding.html#g-base64-decode-step
最佳答案
out_len
参数是一个输出 参数。这意味着您通常会像这样在堆栈上创建 gsize
类型的 out_len
变量:
gsize out_len;
然后调用该函数,将指针传递给上述变量(即传递地址:&out_len
),例如:
decoded = g_base_64_decode(myString, &out_len);
关于c - Base 64解码在C中返回NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39878788/