I am trying to take a wchar_t
string from stdin and then convert it from unicode to ASCII through a function.
The function is somehow not allowing me to use std::string further in the program.
#include <iostream>
#include <string>
#include <locale>
#include <cstring>
#include <cwchar>
using namespace std;
bool UnicodeToAscii(wchar_t* szUnicode, char* szAscii);
int main()
{
wchar_t w[100];
wcin>>w;
char* c;
bool x=UnicodeToAscii(w,c);
cout<<c<<"\n";
string s="hi";
return 0;
}
bool UnicodeToAscii(wchar_t* szUnicode, char* szAscii)
{
int len, i;
if((szUnicode == NULL) || (szAscii == NULL))
return false;
len = wcslen(szUnicode);
for(i=0;i<len+1;i++)
*szAscii++ = static_cast<char>(*szUnicode++);
return true;
}