programmer les bouton de clavier
salut je fait une agenda et je veut limité les bouton de calvier pour cela j'ai fait ce programme
QU : je veut ajouté les bouton de direction
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define BS 8
#define CR 13
int GetDigit()
{
int c;
do
{
c=getch();
}
while ((!isdigit(c)) && (c!=CR) && (c!=BS));
return c;
}
void GetTel(char *t)
{
int c;
int count=0;
char buffer[15];
char *p;
p=buffer;
do{
c=GetDigit();
switch(c)
{
case BS :
if(p!=buffer)
{
printf("\b \b");
count--;
p--;
}break;
case CR :
if(count==9)
{
*p='\0';
strcpy(t,buffer);
printf("\n");
}break;
default :
if(count<9)
{
*p=c;
p++;
putchar(c);
count++;
}
}
}while((count!=9) || (c!=CR));
}
void main()
{
char t[30];
GetTel(t);
} |