0

If we take the standard "Hello world" example, I want to send the output to the current cursor position, NOT to the console window. In fact, I would like the console window to disappear.

What I want to do is basically an autocorrect function: cin >> ae; cout << ä; Grabbing the first part works, but sending the output to the right location proves surprisingly difficult, even after reviewing countless youtube videos...

Bernd
  • 11
  • 3
  • By "cursor position", do you mean the _mouse_ cursor? And when you mention "console window", are you talking about Windows specifically? The question is extremely unclear. The first and second paragraphs of your question do not appear to be related at all. The standard "Hello world" program does not read any input at all. If you're trying to write console-based auto-correction in-place with unbuffered I/O, you'll need to do a lot of work. – paddy Nov 07 '22 at 23:07
  • Standard `c++` alone does not have this ability. You will need a library or OS api. – drescherjm Nov 07 '22 at 23:07
  • Watching YouTube videos is *not* the way to learn a complicated language like C++. Take classes and/or read [good books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and practice daily for a few years. – Jesper Juhl Nov 07 '22 at 23:07
  • Thanks @drescherjm! What library could do this? – Bernd Nov 07 '22 at 23:16
  • Hello @paddy, the cursor as in "ready to accept text". That could be the mouse cursor or not. Confusing for me as well. I'm currently on Windows but want to move over to MacOS. No console! Just the program running in the background. – Bernd Nov 07 '22 at 23:22
  • The general go-to console library is ncurses because it's supported just about anywhere you have a console. Otherwise you rely on target-specific library calls, and without knowing the target platform we can't make decent suggestions. And obviously the target-specific calls do not port off of that target particularly well. – user4581301 Nov 07 '22 at 23:27
  • I was thinking of `ncurses` – drescherjm Nov 07 '22 at 23:28
  • Hello @Jesper Juhl, I don't want to learn the whole C++ language :) I have a functioning autocorrect program, but it only works in Windows, so I need to re-write it. C++ is one of my candidate languages... – Bernd Nov 07 '22 at 23:31
  • The reason why this stuff doesn't work with `cin` and `cout`: They're streams. A cursor is meaningless in a stream. You write to a stream and the data goes *somewhere*. You don't particularly care where, and you may not be able to go back and change a character; it might have been sent to Pluto by then. Streams are too low-level an abstraction for the behaviour you want. – user4581301 Nov 07 '22 at 23:32
  • Plus from the absolute hash autocorrect made out of my last comment, this autocorrect thing... is tricky to get right. That and I need to get better at typing. – user4581301 Nov 07 '22 at 23:38
  • @user4581301, I hear a lot of frustration... :) Anyway, if I have to say farewell to streams, what do you suggest I should look into? – Bernd Nov 07 '22 at 23:46
  • 2
    Frustration at having to weed out so many job candidates because they know how to cut and paste, not program. Start by looking at ncurses. It's an older C library, but it works so well that attempts at converting it to C++ have pretty much been ignored. – user4581301 Nov 07 '22 at 23:57
  • OK, ncurses does not help me :( I want the console to disappear/be minimized and my output to be placed where my text cursor is in a text document. Like a standard autocorrect function (lots of "if input = xx, output = yy, else if..."). Any libraries for that...? – Bernd Nov 09 '22 at 00:51

0 Answers0