| Fun Fun Text |
| << Prev Topic | Next Topic >> |
| ZenithArc |
| Posted: 15-September-2006 at 12:08pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 14-September-2006 Location: United States Posts: 10
|
Anyone know if C++ can, and if so how, to change color of text. Not the 'system("COLOR ##");' command, I mean so I can change single lines, words, or letters.
__________________ "I have defied gods and demons. I am your shield; I am your sword. I know you; your past, your future. This is the way the world ends." - Cortana
|
Online Status: Offline
|
|
| |
| ZenithArc |
| Posted: 15-November-2006 at 9:47pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 14-September-2006 Location: United States Posts: 10
|
No one? Well xsa!
__________________ "I have defied gods and demons. I am your shield; I am your sword. I know you; your past, your future. This is the way the world ends." - Cortana
|
Online Status: Offline
|
|
| |
| DutchDude |
| Posted: 06-June-2007 at 2:45am | IP Logged
|
|
|
Super Dedicated Groupie

Group: Super Dedicated Groupie
Joined: 02-April-2007 Location: Netherlands Posts: 71
|
You mean like in HTML? Where using: <font color="#FF0000">Makes this text color red</font>
if so, techguys
|
Online Status: Offline
|
|
| |
| neWWe}{ |
| Posted: 06-June-2007 at 5:25pm | IP Logged
|
|
|
Dedicated Groupie

Group: Dedicated Groupie
Joined: 07-January-2007 Location: France Posts: 44
|
I think this should help ;)
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
void gotoxy(int x, int y)
{
COORD c;
c.X = x;
c.Y = y;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void textattr(int _attr) {
SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), _attr);
}
the first functions can set the current cursor position so you can
print text anywhere in console and the second sets output attributs
(weight, color, ...)
play with this functions to understand how it works
|
Online Status: Offline
|
|
| |
| tnutty |
| Posted: 04-January-2009 at 1:31am | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 04-January-2009 Location: United States Posts: 1
|
ZenithArc wrote:
Anyone know if C++ can, and if so how, to change color of text. Not the 'system("COLOR ##");' command, I mean so I can change single lines, words, or letters. |
|
|
in visual studio :
its ..
#include"windows.h"
using namespace std;
int main()
{
system("color 100")
return 0;
}
this will help you.
|
Online Status: Offline
|
|
| |
| aica15 |
| Posted: 07-December-2009 at 7:25pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 04-December-2009 Location: Philippines Posts: 1
|
need help! why does the space can't be read by cin.getline.... what should i do???????
|
Online Status: Offline
|
|
| |
| mark707 |
| Posted: 13-January-2010 at 2:11am | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 08-January-2010 Location: Austria Posts: 4
|
spaces can be read with cin.getline()...
i think u mean why space can't be read with cin>>
|
Online Status: Offline
|
|
| |
| m4ster_r0shi |
| Posted: 27-March-2010 at 8:43am | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 26-March-2010 Posts: 4
|
check this out:
------------------------------------------ ------------------------------------------
#include <iostream> #include <windows.h> using namespace std;
enum Color {FBLUE=1,FGREEN=2,FRED=4,FDARK=8, FCYAN=1|2,FPINK=1|4,FYELLOW,FWHITE=1|2|4, BBLUE=16,BGREEN=32,BRED=64,BLIGHT=128, BCYAN=16|32,BPINK=16|64,BYELLOW=32|64,BWHITE=16|32|64, DEFAULT=1|2|4|8};
class ConsoleGraphicsEngine //LOL, like it's DirectX or something... { HANDLE console; public: ConsoleGraphicsEngine() {console=GetStdHandle(STD_OUTPUT_HANDLE);} void set_color(Color c) { WORD attribute=c; SetConsoleTextAttribute(console,c); } };
ostream & operator<<(ostream & os, Color c) { ConsoleGraphicsEngine cge; c=Color(c^FDARK); cge.set_color(c); return os; }
Color operator|(Color c1,Color c2) { Color c=Color(int(c1)|int(c2)); return c; }
int main() { cout << FGREEN << "hello" << FWHITE << "," << endl; cout << (FYELLOW|BBLUE|BLIGHT) << "everyone" << FRED << "!" << endl; cout << FWHITE << "I am the mighty " << FBLUE << "dr" <<FYELLOW << "4" << FBLUE << "gon" << FWHITE << "_" << FRED << "l" << FYELLOW << "0" << FRED << "rd" << endl; cout << DEFAULT;
system("pause"); return 0; }
|
Online Status: Offline
|
|
| |
| 1 User(s) are browsing this topic, 1 Guest(s) and 0 Member(s) |
| 0 Members: |
|
|