Friday, 15 February 2013

Using 'system ("COLOR [attr]")' in C++ -



Using 'system ("COLOR [attr]")' in C++ -

i working on code need display output in different colors according input given user. how can this? tried next code begin with, it's not working.

#include<iostream> #include<cstdlib> using namespace std; int main(void) { scheme ( "title color check" ); for(int i=0;i<10;i++) { scheme ( "color i" ); cout << "this color color" << << endl; } system("pause"); homecoming 0; }

this should work:

for(int = 31; < 38; i++) cout << "\e[0;" << << "m"<< "this color color " << << "\e[0;0m" << endl;

just utilize right color codes:

'\e[0;31m' # red '\e[0;32m' # green '\e[0;33m' # yellow '\e[0;34m' # blue '\e[0;35m' # purple '\e[0;36m' # cyan '\e[0;37m' # white

c++ colors

No comments:

Post a Comment