voici mon prob jia chercher sur le web lequivalent de goto ( x,y) , et des text color sans borland ( jai dev et visual c++) . on ma dit de creer un . c file apeler conio_simple.c et de lapeler avec #include " conio_simple.c" .
mais sa ne marche pas
lol
voici son code
/*
conio_simple.h
Console i/o functions for mingw, tested on 1 turboc program.*/
enum COLORS {BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA,
YELLOW, WHITE};
int directvideo;
extern " C"
{
char* _cgets ( char* szBuffer);
int _cprintf ( const char* szFormat, . ..);
int _cputs ( const char* szString);
int _cscanf ( char* szFormat, . ..);
int getch ( );
int getche ( );
int kbhit ( );
int putch ( int cPut);
int ungetch ( int cUnget);
}
- define _NOCURSOR 100
- define _SOLIDCURSOR 99
- define _NORMALCURSOR 10
- define cgets _cgets
- define cprintf _cprintf
- define cputs _cputs
- define cscanf _cscanf
VOID gettext ( INT x1, INT y1, INT x2, INT y2, LPSTR s);
VOID puttext ( INT x1, INT y1, INT x2, INT y2, LPSTR s);
void _setcursortype ( int type);
void gotoxy ( int x, int y);
void clrscr ( );
void textcolor ( int color);
void textbackground ( int color);
VOID outport ( INT a, INT b);
/*
conio_simple.c
Console i/o functions for mingw, tested on 1 turboc program. */
- include < windows.h>
- include < stdlib.h>
- include < stdio.h>
- include " conio_simple.h"
int __BACKGROUND = BLACK, __FOREGROUND = LIGHTGRAY;
VOID gettext ( INT x1, INT y1, INT x2, INT y2, LPSTR s)
{
INT i, j, n;
SMALL_RECT r;
CHAR_INFO buffer [25] [80];
r = ( SMALL_RECT) {x1 - 1, y1 - 1, x2 - 1, y2 - 1};
ReadConsoleOutput ( GetStdHandle ( STD_OUTPUT_HANDLE),
( _CHAR_INFO *) buffer,
( COORD) {80, 25}, ( COORD) {0, 0}, &);
lstrcpy ( s, " ");
for ( i = n = 0; i < = y2 - y1; i++)
for ( j = 0; j < = x2 - x1; j++)
{
s [n++] = buffer [i] [j].Char.AsciiChar;
s [n++] = buffer [i] [j].Attributes;
}
s [n] = 0;
}
VOID puttext ( INT x1, INT y1, INT x2, INT y2, LPSTR s)
{
INT i, j, n;
SMALL_RECT r;
CHAR_INFO buffer [25] [80];
for ( i = n = 0; i < = y2 - y1; i++)
for ( j = 0; j < = x2 - x1 && s [n] ! = 0; j++)
{
buffer [i] [j].Char.AsciiChar = s [n++];
buffer [i] [j].Attributes = s [n++];
}
r = ( SMALL_RECT) {x1 - 1, y1 - 1, x2 - 1, y2 - 1};
WriteConsoleOutput ( GetStdHandle ( STD_OUTPUT_HANDLE),
( _CHAR_INFO *) buffer,
( COORD) {80, 25}, ( COORD) {0, 0}, &);
}
void _setcursortype ( int type)
{
CONSOLE_CURSOR_INFO Info;
Info.dwSize = type;
SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE), &);
}
void gotoxy ( int x, int y)
{
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE),
( COORD) {x - 1, y - 1});
}
void clrscr ( )
{
DWORD written;
FillConsoleOutputAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE),
__FOREGROUND + ( __BACKGROUND < < 4), 2000, ( COORD) {0, 0}, &);
FillConsoleOutputCharacter ( GetStdHandle ( STD_OUTPUT_HANDLE), ´ ´,
2000, ( COORD) {0, 0}, &);
gotoxy ( 1, 1);
}
void textcolor ( int color)
{
__FOREGROUND = color;
SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE),
color + ( __BACKGROUND < < 4));
}
void textbackground ( int color)
{
__BACKGROUND = color;
SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE),
__FOREGROUND + ( color < < 4));
}
VOID outport ( INT a, INT b) {}
voici celui de mon programe :
- include " conio_simple.c"
int main()
{
clrscty();
textbackground ( GREEN);
textcolor ( RED);
cprintf ( "coucou");
getch();
return 0;
}
je ne compren pas je fait ce kil est ecrit et sa marche pas . ..