#include <iostream>
#include <windows.h>
#include <locale.h>
#include <locale>
using namespace std;
int main()
{
setlocale(LC_ALL, ".UTF-8");
locale global(locale(".UTF-8"));
const float Pi = 3.14;
float r, h;
cout << "Введіть довжину (r): ";
cin >> r;
cout << "Введіть висоту (h): ";
cin >> h;
float d, s, v, sb;
d = 2 * r;
sb = 2 * Pi * r * h;
s = 2 * Pi * r*(r + h);
v = Pi * pow(r, 2) * h;
cout << "d = " << d << "\nSбіч = " << sb << "\nS= "<< s <<"\nV= " << v;
return 0;
}
(English Win11)
I tried:
setlocale (LC_ALL, "ukr";
and
setlocale (LC_ALL, ".UTF-8");
locale global(locale(".UTF-8"));
and
Save documents as Unicode when data cannot be saved in codepage checkbox
and also
edit my region settings.
But nothing of this wont work
>Solution :
This works for me
#include <io.h>
#include <fcntl.h>
#include <iostream>
int main() {
_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"Введіть довжину (r):\n";
return 0;
}
It’s the simple way to print Unicode characters on Windows. Put the stream into _O_U16TEXT mode and use wide strings L"..." and wide streams std::wcout.