printf in Farbe
-
Hi!
Ich weiß nicht so recht ob dies das richtige Forum ist da es ja eigendlich keine MFC Anwendung ist.Also folgendes. Ich will einen bestimmten Teil in Rot anzeigen.
#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { printf ("\n"); printf (" ----------------\n"); printf (" blablabla\n"); printf (" ----------------\n"); printf ("\n"); printf (" ----------------\n"); printf (" blablabla\n"); // Diese Zeile soll in Rot erscheinen! printf (" ----------------\n"); return 0; }
Wie müsste ich den Code umschreiben?
-
Richtig,...das ist kein MFC in einem MFC-Forum.
-
Davon mal abgesehen das google.de mal wieder aus der Mode gekommen ist:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21111512.html
-
Dieser Thread wurde von Moderator/in estartu aus dem Forum MFC (Visual C++) in das Forum DOS und Win32-Konsole verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Verwende doch die "Imporved Console" von SideWinder!
http://www.c-plusplus.net/forum/viewtopic-var-t-is-131915.html
-
#include <windows.h> #include <conio.h> #include <cstdio> #include <iostream> using namespace std; void textcolor(int color) { SetConsoleTextAttribute( ::GetStdHandle(STD_OUTPUT_HANDLE), color ); } /* // Auszug aus conio.h: typedef enum { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE } COLORS;const int WHITE = 15; */ int main() { textcolor(RED); cout << "Das ist rot" << endl; textcolor(BLUE); cout << "Das ist blau" << endl; textcolor(GREEN); cout << "Das ist gr" << char(129) << "n" << endl; // Umlaut ü textcolor(WHITE); cout << "Das ist weiss" << endl << endl; for(int i=0; i<16; ++i) { textcolor(i); cout << "Das ist Farbe: " << i << endl; } cout << endl << "H" << char(148) << "fliche G" << char(132) << "ste im Gr" << char(129) << "nen haben Spa" << char(225) << "." << endl; cout << char(132) << char(148) << char(129) << char(225) << endl; getch(); }