Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

static vector<vector<uchar>> res[RES] = {}; foreach (r, res[s]) { vector<uchar> tmp;…

  1. User

    static vector<vector<u_char>> res[RES] = {}; foreach (r, res[s]) { vector<u_char> tmp; memcpy(tmp, r, r.size()); memcpy(tmp, r, r.size()); } no suitable conversion function from "std::__1::vector<u_char, std::__1::allocator<u_char>>" to "void *" existsC/C++(413)

  2. Assistant

    This error message suggests that there is no appropriate conversion function to convert a vector of unsigned characters (u_char) into a pointer to void, which is what is expected by the second parameter of the memcpy function.

    To resolve this error, you need to use the address-of operator (&) to pass the address of the first element of the vector to memcpy:

    static vector<vector<u_char>> res[RES] = {}; foreach (r, res[s]) { vector<u_char> tmp; memcpy(&tmp[0], &r[0], r.size()); }

    Alternatively, you could use the data() member function of the vector, which returns a pointer to the underlying data of the vector:

    static vector<vector<u_char>> res[RES] = {}; foreach (r, res[s]) { vector<u_char> tmp; memcpy(tmp.data(), r.data(), r.size()); }

    Note that in both cases, you also need to allocate enough memory for the destination vector before copying the data.