For example, I write 'std :: cout << 5'. How do I then read this value from the console? Upd: do not enter it yourself, but consider what has already been output. What does it matter which program? If only the value remains ... Comments from the mobile do not work

  • In order to display a specific value, you must first declare a variable in your case, it can be int n; then initialize std::cin>>n; from the keyboard std::cin>>n; and then, if desired, display using std::cout<<n; If I understood correctly. - Semyon Shelukhin
  • Where to count? Another program? - Anton Shchyrov
  • I propose to ask the question, not from the "mobile", when comments will work - Sublihim
  • Well, you need to take a console buffer using the appropriate API functions, specify the coordinates of exactly where you want to read, and read ... Is this worth the candle? And yet - if this is another program, then just a pipe | redirect her output to your input and do not suffer :) - Harry

1 answer 1

judging by the question, does your program need access to the output history?

then you need to implement your input / output streams: my :: out, which stores a copy of the data in memory (a typical implementation is a ring buffer), and my :: in, which can climb into the buffer with old data.