#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
/*
dkchoice /c[:]Choices /n /s [msg]
*/
int main(int argc,char **argv)
{
int c;
char *p;
char *q;
if ( argc < 3 ) {
printf("dkchoice /c[:]Choices /n /s [msg]\n");
return 255;
}
q = argv[1] + 2;
if ( *q == ':' ) q++;
if ( argc >= 5 ) {
printf("%s",argv[4]);
}
do {
c = getch();
if ( c == 0 ) {
c = getch();
c = 0;
} else if ( c == 3 ) {
printf("^C\n");
return 0;
}
p = strchr(q,c);
} while ( c == 0 || p == NULL );
printf("%c\n",c > ' ' ? c : ' ');
return p - q + 1;
}
up