c++ pwstr to char*

#include <iostream>
#include <Windows.h>

int main() {
    const wchar_t* pwstr = L"Hello, World!"; // Wide character string
    int size = WideCharToMultiByte(CP_UTF8, 0, pwstr, -1, NULL, 0, NULL, NULL);
    char* pstr = new char[size];
    WideCharToMultiByte(CP_UTF8, 0, pwstr, -1, pstr, size, NULL, NULL);

    // Use the char* string (pstr) as needed

    delete[] pstr;
    return 0;
}