#include <iostream>
#include <cstdlib>
#include <string>

std::string wstring_from_bytes(std::wstring const& wstr)
{
    std::size_t const size = sizeof(wstr.c_str());
    char *str = new char[size];
    std::string temp;

    std::wcstombs(str, wstr.c_str(), size);

    temp = str;

    return temp;
}

int main()
{
    std::wstring wstr = L"abcd";
    std::string str = wstring_from_bytes(wstr);

    std::cout << str;
}