Hello.
Recently, I decided to return to learning C ++, but since my level of knowledge is catastrophically low, I came here again :) Today I want to try to do something like a typewriter. It sounds loud, but I will explain what the essence is. Console application in C ++. The user enters his text, and then the field is cleared and the computer starts typing the text at quarter intervals (for example) seconds between characters.
Since I came here to learn, I will try to express my ideas. From what I know, Sleep is needed here, most likely the use of arrays and loops. It seems like it should be easy. In my head flashed the idea that each character from the text should be made to the array. Or replace the variable. That is, the value of the variable is replaced with a text symbol every time, and at a quarter-second interval it is displayed on the screen as long as there are characters in the entered text.
I will be grateful to those who will help to understand a little, and better push to the decision.
UPDATE
#include <iostream> #include <Windows.h> using namespace std; int main() { char string str[]; cout << "Type your text"; cin >> str; for (int i = 0; i<=str.Length - 1; i++) { cout << str[i]; Sleep(200); } system("pause"); }
That's what happened with me. This gives an error. What is wrong here?