0
Why is this code showing compilation error?
5 Answers
+ 3
Because while copying/pasting your code to the playground some illegal characters from the document in which you copied the code is also got paste there.
See this: cpp.sh/7c4u5
+ 3
"Is it valid?"
To some extent!
To make it possible to correctly handle the wide character set (e.g. Unicode) you'd do it this way
#include <iostream>
#include <stdio.h>
#include <io.h> // Windows-specific header
#include <fcntl.h>
using namespace std;
int main()
{
_setmode(_fileno(stdout), _O_U8TEXT); // Sets the file translation mode š
wprintf(L"\xFEFF"); // Byte order mark (magic number necessary to work with Unicode) ²
wchar_t w = L'ب';
//wcin >> w;
wcout << L"Wide character value:: " << w << endl;
return 0;
}
Output:
ب
_____
š https://docs.microsoft.com/en-us/previous-versions/tw4k6df8(v=vs.140)
² https://en.wikipedia.org/wiki/Byte_order_mark
https://code.sololearn.com/cWtSLDT8JYCn
+ 1
Some special symbol are present inn your code so it giving error this special symbol come because of copy the code from your notepad to sololearn fixed now
https://code.sololearn.com/cpkcP36Vikzf/?ref=app
+ 1
Thanks for helping đ
0
Can you please tell me a way to take input from user which I want to assign to a variable of wchar_t data type? I found this way. Is it valid?
https://code.sololearn.com/c91P7zSbxnwM/?ref=app