C++ Data-Url as String to const byte*

Ale*_*der 5 c++ string byte

我有一个文件的Data-Url作为std:string.必须对base64编码数据进行解码,然后将其传递给此函数:

open (const byte *  data, long size)
Run Code Online (Sandbox Code Playgroud)

所以首先我提取编码数据

size_t pos = dataurl.find_first_of(',');
std::string encoded = dataurl.substr(spos + 1);
Run Code Online (Sandbox Code Playgroud)

然后我使用这个base64解码器

std::string decoded = base64_decode(encoded);
Run Code Online (Sandbox Code Playgroud)

那么,我如何将类型字符串的'解码'转换为字节*?以下代码会产生错误

open((byte *)decoded.c_str(), decoded.size() + 1);
//>>error: 'byte' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

/编辑:所以有一个typedef

typedef uint8_t     byte
Run Code Online (Sandbox Code Playgroud)

编码数据是图像!

Gor*_*bot 1

看来您正在删除const. c_str()返回一个const char *. 你的演员阵容应该是(const byte *)