I am learning about wstrings because I want to understand UTF-8 for a project. I made a simple program to test operations using wstrings:
int main()
{
std::wstring test;
std::wstring test2;
std::wstring test3;
int n;
getline(std::wcin, test);
std::wcout << "\n" << test;
for (n = 0; n < test.size(); n++)
{
test[n] += n * n;
test2[n] = test[n];
}
std::wcout << test2 << "\n";
for (n = 0; n < test2.size(); n++)
{
test2[n] -= n * n;
test3[n] = test[n];
}
std::wcout << test3 << "\n";
return 0;
}
When I execute it I get this error : "string subscript out of range"
It's my first C++ "serious" project and any help is appreciated!