Open obroad opened 11 months ago
I'm seeing that this is the preferred solution compared to the older console API [...]
That's not quite correct. WriteConsole
and WriteFile
are entirely valid ways to write text to the terminal on Windows for now and the future, because those two are the underlying Win32 APIs. wprintf
is simply one of the preferred approaches when writing C specifically, because it integrates into the rest of the standard library including its locale support.
Basically, WriteConsole
vs. wprintf
is similar to CreateThread
vs. std::thread
(in C++).
I'm not familiar with the old API and this article appears to be written for experienced developers.
Frankly, I unfortunately would not agree that the Microsoft documentation is the right place to learn C/C++. While I feel compassionate for you, I personally believe you can use one of the many specialized learning websites to get more familiar with those C APIs and learn their difference and meaning. They'll do a much better job at this than we ever could.
But to answer your questions...
[...] but the examples use wprintf in one case and printf in the other [...]
The difference between wprintf
and printf
is simply whether you'd like to use char
(ASCII or UTF-8) or wchar_t
(UCS-2, a subset of UTF-16) for your strings. Both work perfectly fine for printing VT sequences however and you can use them both simultaneously. (I would strongly recommend sticking to one of the two though.)
and I would like to see examples of accepting character input.
The equivalent to (w)printf
for reading input is (w)scanf
. You can read its documentation here:
I'm not sure what the best way to learn how to use scanf
is, but there are a ton of tutorial websites out there.
I'm seeing that this is the preferred solution compared to the older console API and I can see the potential to be more portable but the examples use wprintf in one case and printf in the other and I would like to see examples of accepting character input. I'm not familiar with the old API and this article appears to be written for experienced developers.
Also is there an existing "wrapper" API that provides functions to emit the required escape sequences?
[Enter feedback here]
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.