| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1074 人关注过本帖
标题:编写了一个登陆程序,有BUG,有大神能看看嘛?
只看楼主 加入收藏
caishou
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2019-12-21
收藏
 问题点数:0 回复次数:0 
编写了一个登陆程序,有BUG,有大神能看看嘛?
想编写一个登陆程序,把登陆密码以文本文档的形式储存在电脑,可运行程序后,打开文件调用
后生成的文档不为空,导致无法检测有无密码。请问怎么哪里有问题?
图片附件: 游客没有浏览图片的权限,请 登录注册

程序代码:
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include "ENPASS_H.h"
#define SIZE 10

void password_login(){ /*密码函数*/
   
    char pwd[5];
    int i = 3;
    int n = 4;
    char str[5];
    int x =0;
    
    char *pp = NULL;
   
      FILE *fp;
      
    
    if((fp = fopen("D:\\1.txt","a+")) == NULL)
        {
        printf("sorry,can't open the password file.");
        exit(1);
        }
         
    fgets(str,5,fp);
    if(str[0] == '\0')
        {
        printf("000");
        printf("please input new password:\n");
        scanf("%s",str);           
        fputs(str,fp);
        fclose(fp);
        printf("OK!\n");
        system("cls");
        Sleep(1200);
        }
   a:
       for(x=0;x<SIZE;x++)
       {
           printf("%d\n",str[x]);
       }
    printf("please input password:\n"); 
    
    scanf("%s",pwd);
    
    if(!strcmp(str,pwd)){
        printf("This password is true.");
        Sleep(1000);
        system("cls");
    
        
    }else{

        Sleep(500);
        system("cls");
        --i;
        printf("False,You just have %d times to input password.\n",i);
              
            if(i == 0)
                {
                printf("Sorry,you have no times to input.\n");
                printf("Program will exit.");
                Sleep(500);
                exit(0);
                }
            else{
                goto a;
                }
            
         }
    return ;
      }
搜索更多相关主题的帖子: password str 登陆 printf include 
2019-12-21 19:07
快速回复:编写了一个登陆程序,有BUG,有大神能看看嘛?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019258 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved