entire code is below link. base64 decode snippet in c++ I have a question about const pointer in above link code.
main
std::vector<BYTE> myData;
...
std::string encodedData = base64_encode(&myData[0], myData.size());
base64_encode
std::string base64_encode(BYTE const* buf, unsigned int bufLen) {
std::string ret;
int i = 0;
int j = 0;
BYTE char_array_3[3];
BYTE char_array_4[4];
while (bufLen--) {
char_array_3[i++] = *(buf++);
if (i == 3) {
parameter is BYTE const* buf, not const BYTE* buf.
when const BYTE* buf is used as parameter, const is for BYTE, so pointer can be changed but the value of buffer can not be changed.
when BYTE const* buf is used, const is for pointer variable, so value can be changed but address can not be changed.
in above code, buf pointer is const, but buf++ is possible?
and why BYTE const* buf is used instead of const BYTE* buf?
thanks