Review / Advice

Pages: 12
Got those all converted over to that too. Only the last problem with the VT100 ANSI escape strings. It works in my compiler, but if I compile the project via CMake it just straight outputs the escape stirng. Not really sure how to prevent that from happening. Don't want to use the windows header and utilizing the setconsoletextattribute. It just would seem silly for this simple of a program to not work everywhere.
The VT100 ANSI escape strings only work within the Windows console if VT100 is supported and enabled. For Windows this is from Windows 10. You first need to enable VT100 support for the console. See https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

An alternate way to colorize your text, usable on Windows, a header only approach:

https://cplusplus.com/articles/Eyhv0pDG/

It never hurts to know more than one way to code something. This approach doesn't require Win 10's ability to use VT100 coding, its a deep-dive into the WinAPI that works with earlier Win versions.

I can't say if it would work with Win 11, I don't use that.
Another way for color output is the fmt library.
https://github.com/fmtlib/fmt

Shame that isn't included in std::fomat.
Using {fmt} would arguably be a better solution since theoretically using it would be cross platform. Not tied to Windows.

Maybe the C++ ISO Committee will consider possibly including the terminal color API in a future standard.

I ain't holdin' my breath.

I was hoping shoehorning {fmt} into Visual Studio would pay off, now I have a reason to use it. :D
If FMT is cross platform, I will be switching to it. I had to reinclude the windows header before I turned it in. But that doesn't mean I don't care about the project. Once it's graded I will switch over to fmt and probably switch it to plain jane Wordle that has a list of 5 character word's and will randomly select one for the user to guess. It should be fun to implement but seeing as this is a freshman class this should be an easy 100.

I really appreciate everyone's help. It's been 10 years since I took AP CS in high school and 2 years of CS and 1 year of web programming before that. In high school we utilized Java and I feel like that confused me on OOP a ton.

I am really happy with where the project is now and the feedback you all provided was fantastic. I am really thankful to now be part of a community of individuals like yourselves and really hope to not embarrass myself further.
One cool aspect of the {fmt} library, as well as C++20's <format>, is formatting text with a C++ version of the C printf function. The C++ standard committee "borrowed" most of {fmt} for their C++20 <format> library.

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <fmt/core.h>

int main()
{
   int answer = 42;

   std::cout << fmt::format("The answer is {}.\n", answer);
}
The answer is 42.

Now do you see why I suggested you post your code here? You've gotten a lot more and better help than relying on us to dink around your code from github, :)

If you are on Windows and using Visual Studio 2019/2022 there is a package manager that makes installing {fmt} easy, vcpkg.

https://vcpkg.io/en/index.html

When I was "krufting" that example above VS Intellisense found the header I used for {fmt} as easily as any header from the C++ standard library, no need to manually set project settings to find the library.
Last edited on
Topic archived. No new replies allowed.
Pages: 12