代码示例设计密码:
#define MAXLINE 255
char * cy_gets()
{
static char t[ MAXLINE ];
char ch;
int flag=0,i=0;
for ( ; i < MAXLINE; )
{
ch = getch();
switch( ch )
{
case \'\\r\':
case \'\\n\':
t[i] = \'\\0\';
return t;
case \'\\b\':
if ( i > 0 )
i--;
if ( i == 0 )
flag++;
if ( i>0||flag==1 )
{
putch( \'\\b\' );
putch( \' \' );
putch( \'\\b\' );
}
break;
default:
t[i] = ch;
i++;
flag = 0;
if ( ch == \' \' )
putch( \' \' );
else
{
putch( \'*\' );
putch( \'\\a\' );
}
}
}
t[ MAXLINE - 1 ] = \'\\0\';
return t;
}