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

本文介绍了一个使用C语言编写的简单密码验证程序。该程序通过控制台接收用户输入的密码,并以星号显示来隐藏实际字符,确保密码的安全性。程序还实现了密码长度限制及错误提示等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#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()


{

       char szPassword[128];

       GetPassword(szPassword);


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


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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值