Quote:
Don,
Thanks for the input. Sorry, I should have been more specific. case 3 "does" print white... because I've only tested this on a tty with black bg and white fg.
When it is compiled on the Windoze side, they'll be using a black and white terminal, so it's not that big of a deal, but that's no reason for sloppy code. That said, I have about a half dozen other boxes I work on, each having their own bg / fg color combos. Just so I know what machine I'm working on. I'll have to see what output they yield.
Like I said, I haven't used C for years. This project is just getting the juices flowing. I've been pulling snippets from some of my old code. Heck, I look back at some of it, some 15+ years old, and say. I DID THAT?!?!?
For now I'm taking the KIS (Keep It Simple) approach. Your example is a bit much to digest at the moment. However, reading through it does help!
The ANSI terminal escape sequence you're using for case 3 produce black text on a white background. Having your terminal set to invert foreground and background colors makes it appear as white text on a black background when it is rendered on your screen.
I fully understand and appreciate KISS principles.
Here you have a choice between having an output function to print string arguments, an output function to print integer arguments, and an output function to print floating point arguments; or a single function that can handle all three. If you need to worry about various types of integers (int, long, long long) and floating point (float, double, long double) arguments then the processing gets more complicated. If you want to pass this routine a format string that ends with anything other than a
printf() conversion specifier character, then the processing gets considerably more complicated (as in you'd have to actually interpret the entire format string argument instead of just the last character). There is also the question of what needs to be simple? Does it need to be simple for the person writing the
output*() function (or functions), or does it need to be simple for the person using those functions? (Of course, in this case both of those might be the same person!)
Programming is full of trade-offs. I just wanted to give you some options to consider.