| | |
How to code a program that can show color text output???
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Just somthing I made with the bit of info I learned from this thread. It also can be a simulation of those "test" the video broadcasters do for some reason. Let me know what you guys-n-gals think LOL :cheesy:
C Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <windows.h> int color(); int main() { int c; for (c = 0; c < 24; c++) { color(); } system("pause"); return 0; } int color() { HANDLE hConsole; int k = 0, r; for (r = 0; r < 16; r++) { hConsole = GetStdHandle(STD_OUTPUT_HANDLE); k; SetConsoleTextAttribute(hConsole, k); cout << "ÛÛÛÛÛ"; // Alt 219 (a square) extended ASCII character k++; } return 0; }
>I think you should leave C++ alone. Go play with QBasic, as it's more your style.
I think you should be silent unless you have something useful to add. Flames are fine as long as they're deserved, but in this case your comments are completely uncalled for.
>Oh, and Dexter's Laboratory sucks.
Personal opinions have no place here unless they're related to C or C++ and carefully worded to make it clear that they're opinions.
If you want to be an ass, at least do it tastefully.
>Let me know what you guys-n-gals think LOL
Well, I think that LOL should only be used in response to something incredibly funny, if at all. Using LOL in response to a statement you make gives the impression that you're a lamer.
Aside from that, the code could be formatted better, it could be reorganized, and you make an assumption about the size of the console window. Here's another way to go about it:
All in all, a nice program. Well done.
I think you should be silent unless you have something useful to add. Flames are fine as long as they're deserved, but in this case your comments are completely uncalled for.
>Oh, and Dexter's Laboratory sucks.
Personal opinions have no place here unless they're related to C or C++ and carefully worded to make it clear that they're opinions.
If you want to be an ass, at least do it tastefully.
>Let me know what you guys-n-gals think LOL
Well, I think that LOL should only be used in response to something incredibly funny, if at all. Using LOL in response to a statement you make gives the impression that you're a lamer.
Aside from that, the code could be formatted better, it could be reorganized, and you make an assumption about the size of the console window. Here's another way to go about it:
C Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <windows.h> void color(); int main() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); COORD windowSize = GetLargestConsoleWindowSize(hConsole); for (SHORT c = 0; c < windowSize.Y; c++) { color(); } std::system("pause"); return 0; } void color() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); WORD k = 0; const int colors = 16; for (int r = 0; r < colors; r++) { SetConsoleTextAttribute(hConsole, k++); std::cout << "ÛÛÛÛÛ"; // Alt 219 (a square) extended ASCII character } }
New members chased away this month: 3
•
•
•
•
Originally Posted by Geek-Master
Just somthing I made with the bit of info I learned from this thread. It also can be a simulation of those "test" the video broadcasters do for some reason. Let me know what you guys-n-gals think LOL :cheesy:
C Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <windows.h> int color(); int main() { int c; for (c = 0; c < 24; c++) { color(); } system("pause"); return 0; } int color() { HANDLE hConsole; int k = 0, r; for (r = 0; r < 16; r++) { hConsole = GetStdHandle(STD_OUTPUT_HANDLE); k; SetConsoleTextAttribute(hConsole, k); cout << "ÛÛÛÛÛ"; // Alt 219 (a square) extended ASCII character k++; } return 0; }
May 'the Google' be with you!
•
•
Join Date: Mar 2004
Posts: 1,620
Reputation:
Solved Threads: 51
Play nice people. Attitude, name calling, grumpy behavior, or posting without having your Wheaties in the morning will not help us become better coders. And we all should admit that sometimes the documentation / examples that are in the book, or online resource, do not jump out and click.
Locking thread to encourage better use of our time.
Christian
Locking thread to encourage better use of our time.
Christian
![]() |
Other Threads in the C Forum
- Previous Thread: algorithm uses in scheduling between RAM and CPU
- Next Thread: Open GL
| Thread Tools | Search this Thread |
Tag cloud for C
#include ansi array arrays asterisks binarysearch calculate centimeter changingto char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware histogram homework inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures student systemcall testing threads turboc unix user variable voidmain() wab windowsapi





