2012-7-16可樂的密码输入源代码

来源:互联网 发布:网络线路延长器 编辑:程序博客网 时间:2024/05/17 08:49

#include<stdio.h>

#include<string.h>

#define Max_PASSLEN 128

 char tpss[20]="admin";
    void GETPassword(char*szFinalPass)
    {
      char chValue,szPassword[MAX_PASSLEN];
      int iCounter=0;

      while(1)
      {
       if((chValue=getch())!='\r') 

       {
        if(chvalue!='\b')         

        {
          if(iCounter<MAX_PASSLEN) 

          {
           szPassword[iCounter]=chValue;                        
            putchar('*');  

            iCounter++;              
        
        else
        {
         putchar('\error');    

                              
       }
       else
       {
        if(iCounter!=0) 

        {
         iCounter--;
         printf("\b\b");  

       
         
           
      }
      else
    {
     szPassword[iCounter]=0; 

     break;
    }
    strcpy(szFinal,szPassword);  

    
    int main()


{

       charszPassword[128];

      GetPassword(szPassword);


 if(strcmp(szPassword,tpass)==0)
        printf("\n the pssword is:%s\n",szPassword);


 else
        printf("\n  error\n");
 
 

原创粉丝点击