Here is the task:
Create a program that must receive a sequence of digits at the input, after which the program displays the digit whose sequence number the user entered.
And here is my code:
#include <iostream> #include <cstring> using namespace std; int main() { setlocale(LC_ALL, "Russian"); char string[100]; cout << "Введите последовательность цифр: "; cin >> string; int k; cout << "\nВведите порядковый номер цифры: "; cin >> k; if ((k - 1) < 0 || k > strlen(string)) cout << "\nНекорректный ввод порядкового номера" << endl << endl; else cout << "\nk-я цифра последовательности: " << string[k] << endl; return 0; } However, it does not work. Where is the mistake?
nin the lines of outputnwith\n- Harry