#include <iostream> |
#include <Windows.h> |
#include <stdio.h> |
#include <stdarg.h> |
using namespace std; |
void cprintf( char * str, WORD color, ...); |
int main() { |
cprintf( "H" , 10); |
cprintf( "e" , 9); |
cprintf( "l" , 12); |
cprintf( "l" , 11); |
cprintf( "o" , 13); |
cprintf( " " , 10); |
cprintf( "W" , 15); |
cprintf( "o" , 2); |
cprintf( "r" , 5); |
cprintf( "l" , 8); |
cprintf( "d" , 14); |
cprintf( "!" , 4); |
return 0; |
} |
void cprintf( char * str, WORD color, ...) { |
WORD colorOld; |
HANDLE handle = ::GetStdHandle(STD_OUTPUT_HANDLE); |
CONSOLE_SCREEN_BUFFER_INFO csbi; |
GetConsoleScreenBufferInfo(handle, &csbi); |
colorOld = csbi.wAttributes; |
SetConsoleTextAttribute(handle, color); |
cout << str; |
SetConsoleTextAttribute(handle, colorOld); |
} |
初级程序员
by: 我的程序员之路 发表于:2013-05-05 20:21:01 顶(0) | 踩(0) 回复
关键在于 cprintf 函数哦
网友回复
回复小蜜锋 : 应该是windows api
顶(0) 踩(0) 2013-05-17 23:17:51
回复评论