Actualiser main.c
This commit is contained in:
parent
9b1e6a43e5
commit
b0a8db8777
64
main.c
64
main.c
@ -1,46 +1,48 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void Locate(int x,int y)
|
void Locate(int x,int y)
|
||||||
{
|
{
|
||||||
HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
COORD C;
|
COORD C;
|
||||||
C.X=(SHORT)x;
|
C.X=(SHORT)x;
|
||||||
C.Y=(SHORT)y;
|
C.Y=(SHORT)y;
|
||||||
SetConsoleCursorPosition(H,C);
|
SetConsoleCursorPosition(H,C);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Afficher(int curs)
|
void Afficher(int curs)
|
||||||
{
|
{
|
||||||
Locate(0,0);
|
Locate(0,0);
|
||||||
printf("%c Oui\n",(curs==0)?'>':' ');
|
printf("%c Oui\n",(curs==0)?'>':' ');
|
||||||
printf("%c Non\n",(curs==1)?'>':' ');
|
printf("%c Non\n",(curs==1)?'>':' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
int Choisir()
|
int Choisir()
|
||||||
{
|
{
|
||||||
int curs = 0;
|
int curs = 0;
|
||||||
int touche;
|
int touche;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Afficher(curs);
|
Afficher(curs);
|
||||||
touche = _getch();
|
touche = _getch();
|
||||||
if (touche==0xE0) // fleche : le code fleche renvoie 2 caracteres.
|
if (touche==0xE0) // fleche : le code fleche renvoie 2 caracteres.
|
||||||
{
|
{
|
||||||
touche = _getch();
|
touche = _getch();
|
||||||
if (touche==0x50 && curs==0) // fleche bas
|
if (touche==0x50 && curs==0) // fleche bas
|
||||||
curs = 1;
|
curs = 1;
|
||||||
if (touche==0x48 && curs==1) // fleche haut
|
if (touche==0x48 && curs==1) // fleche haut
|
||||||
curs = 0;
|
curs = 0;
|
||||||
|
}
|
||||||
|
} while (touche!=0x0D); // enter
|
||||||
|
return curs;
|
||||||
}
|
}
|
||||||
return curs;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int choix;
|
int choix;
|
||||||
choix = Choisir();
|
choix = Choisir();
|
||||||
Locate(0,3);
|
Locate(0,3);
|
||||||
printf("Vous avez choisi : %s\n",(choix==0)?"Oui":"Non");
|
printf("Vous avez choisi : %s\n",(choix==0)?"Oui":"Non");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user