如何用C语言编写密码程序

Python013

如何用C语言编写密码程序,第1张

1、用一个字符数组来存密码

再用一个字符数组接收你的输入,然后用strcmp

来比较,如果返回0则密码是正确的

2、例程:

#include "stdio.h"

#include "string.h"

int main()

{

       char mima[100]="YuanShi888"

       char input[100]={0}

       printf("请输入密码:")

        gets(input)

       if(strcmp(mima,input)==0)

            printf("恭喜你,密码正确!\n")

       else

            printf("对不起,密码输入错误!\n")

  

}

#include void main() { FILE *fpfp=fopen("password.txt","r+")long pass,paschar chpass=0do{ ch=fgetc(fp)pass=10*pass+ch-48}while(ch!=-1)rewind(fp)printf("input password:") scanf("%ld%*c",&pas)if(pas==pass) { p...