Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.

C++ outputs strange symbols instead of text entered from the keyboard. The message "Введите слово" displays correctly, the number of letters is also correctly counted, and then something happens to the word, incomprehensible characters are displayed instead, and as a result the program does not work correctly (the problem is the same with Cyrillic, Latin, and numbers ".

#include
#include
#include

using namespace std;
char a[1][50];
int lenght, i, j, f = 0;
int main() {
setlocale(LC_ALL, "rus");
cout << "Введите слово\n";
cin >> a[1];
lenght = strlen(a[1]);
cout << "Длина слова: " << lenght << endl;
cout << a[1] << endl;
for (j = 0; j <= lenght; j++) {
if (a[1][j] == a[1][lenght - j]) continue;
else {
f = 1;
break;
}
}
if (f == 0) cout << "Введенное слово является полиндромом";
else cout << "Введенное слово не является полиндромом";
}


Sagot :