☰
✕
Главная
© 2002 - 2025
Diary.ru
Close the sidebar
Консоль в винде
adjective
| понедельник, 04 июня 2012
Ad
Как обычно, в силу @#$#$ свойств системы не которые функции (именно эта) не будет нормально работать с растровыми шрифтами.
#include <stdio.h> #include "windows.h" void ChangeColour(WORD theColour) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to standard output SetConsoleTextAttribute(hConsole,theColour); // set the text attribute of the previous handle } void gotoxy(int a,int b) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to standard output SetConsoleCursorPosition(hConsole,(COORD){ X : a, Y: b} ); // set the text attribute of the previous handle // COORD boo; // boo.x=a; boo.y=b; // SetConsoleCursorPosition(hConsole,boo); // SetConsoleCursorPosition(hConsole,(COORD)((b<<16)+a)); } int main() { UINT outCP=GetConsoleOutputCP(); UINT inCP=GetConsoleCP(); UINT w = 1251; // ANSI codepages don't work with raster fonts // printf("Setconsole returned = %d\n",SetConsoleCP(w)); printf("Setconsoleo returned = %d\n",SetConsoleOutputCP(w)); ChangeColour(0x17); // Set the foreground colour to be blue gotoxy(1,1); printf("This text is white\n"); gotoxy(40,5); printf("╠╚╨╙ ╠╚╨!"); gotoxy(25,25); for(int i=0;i<16;i++) { for(int j=0;j<16;j++) { ChangeColour(i*16+j); gotoxy(j*2,i); printf("8 "); } } SetConsoleOutputCP(outCP); SetConsoleCP(inCP); ChangeColour(0x07); return 0; }
З.Ы. в венде есть команда
chcp
, которая делает смену кодировки
IT
cpp
Смотрите также
... Все это – сон, мечта, каприз...
BWV 565
Artesanato Simples Ed.48 Tapetes: Circulares e Infantis
Быть или не быть
***
14. Blackpepper "Шеф Ким и помощник управляющего Чхве"