CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

probleme avec un .c

lord_kalipsy
lord_kalipsy
Niveau 10
01 septembre 2003 à 04:32:49

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);
}

  1. define _NOCURSOR 100
  2. define _SOLIDCURSOR 99
  3. define _NORMALCURSOR 10
  4. define cgets _cgets
  5. define cprintf _cprintf
  6. define cputs _cputs
  7. 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. */

  1. include < windows.h>
  2. include < stdlib.h>
  3. include < stdio.h>
  4. 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 :

  1. 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 . ..

spook2
spook2
Niveau 7
01 septembre 2003 à 09:40:58

si tu regardai un peu le header tu verrai que c´est normal....
ces 2 fonction prenent un entier en parametre
textbackground ( int);
textcolor ( int);

et toi tu met une chaine.

lord_kalipsy
lord_kalipsy
Niveau 10
02 septembre 2003 à 03:47:17

je te fais remarker ke tu mettre GREEN a la place de 4

lord_kalipsy
lord_kalipsy
Niveau 10
02 septembre 2003 à 16:09:54

:up: sa marche po ton truc

lord_kalipsy
lord_kalipsy
Niveau 10
02 septembre 2003 à 19:30:45

:up:

lord_kalipsy
lord_kalipsy
Niveau 10
03 septembre 2003 à 02:04:02

:up:

lord_kalipsy
lord_kalipsy
Niveau 10
04 septembre 2003 à 02:56:22

:up:

Diwi
Diwi
Niveau 5
04 septembre 2003 à 10:11:54

Tiens, je t´ai tout mis dans un seul fichier, tu devrais y arriver :

/*
conio_simple.h
Console i/o functions for mingw, tested on 1 turboc program.*/

  1. include < windows.h>
  2. include < stdlib.h>
  3. include < stdio.h>

enum COLORS {BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA,
YELLOW, WHITE};
int directvideo;

  1. define _NOCURSOR 100
  2. define _SOLIDCURSOR 99
  3. define _NORMALCURSOR 10
  4. define cgets _cgets
  5. define cprintf _cprintf
  6. define cputs _cputs
  7. 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. */

int __BACKGROUND = BLACK, __FOREGROUND = LIGHTGRAY;

void gettext ( int x1, int y1, int x2, int y2, LPSTR s)
{
int i = 0;
int j = 0;
int n = 0;
SMALL_RECT r;
CHAR_INFO buffer [25][80];
r = ( SMALL_RECT) {x1 - 1, y1 - 1, x2 - 1, y2 - 1};
ReadConsoleOutput ( GetStdHandle ( STD_OUTPUT_HANDLE), ( PCHAR_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),
( PCHAR_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;
CHAR a = ´ ´;
FillConsoleOutputAttribute ( GetStdHandle(STD_OUTPUT_HANDLE), __FOREGROUND + ( __BACKGROUND < < 4), 2000, ( COORD) {0, 0}, &);
FillConsoleOutputCharacter( GetStdHandle(STD_OUTPUT_HANDLE), a, 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) {}

int main()
{
clrscr();
textbackground ( GREEN);
textcolor ( RED);
cprintf ( "coucou");
getch();
return 0;
}

Diwi
Diwi
Niveau 5
04 septembre 2003 à 10:12:58

Tu auras juste à supprimer tous les doubles espaces qui font un peu chier ( tu fais un remplacement général de tous les doubles espaces en rien).

Sinon, j´ai testé, il marche comme il faut la.

Sous forums
  • Aide à l'achat Mac
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment