C++
1#include <iostream>
2#include <string>
3#include <thread>
4using namespace std;
5
6bool keyin = false;
7
8void f(int n)
9{
10 string s;
11 getline(cin, s);
12 keyin = true;
13}
14
15int main()
16{
17 thread th(f, 1);
18 for (char c = 'a'; c <= 'z'; c++) {
19 if (keyin) {
20 cout << "key input detected\n";
21 keyin = false;
22 }
23 cout << c << flush;
24 this_thread::sleep_for(chrono::milliseconds(500));
25 }
26 th.join();
27 cout << endl;
28}
コメントをお願いします。