A. 如何用c语言编写密码程序
1、用一个字符数组来存密码
再用一个字符数组接收你的输入,然后用strcmp
来比较,如果返回0则密码是正确的
2、例程:
#include"stdio.h"
#include"string.h"
intmain()
{
charmima[100]="YuanShi888";
charinput[100]={0};
printf("请输入密码:");
gets(input);
if(strcmp(mima,input)==0)
printf("恭喜你,密码正确! ");
else
printf("对不起,密码输入错误! ");
}
B. c语言程序设计 密码设置程序怎么编写
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main(int argc,char *argv[])
{
const char user[]="wangpin";/*用户名自己可改动*/
const char password[]="wangpin@126";/*密码自己可改动*/
if(argc == 1)
{
printf("Input error! Usage:filename username password\n");
getch();
exit(1);
}
else if(argc == 3)
{
if (strcmp(argv[1],user) != 0 || strcmp(argv[2],password) != 0)
{
printf("Input error: Invalid username or password\n");
getch();
exit(1);
}
}
printf("Authentication Pass..\n");
sound(500);/*最简单的音乐声*/
delay(50000);
nosound();
getch();
return 0;
}
先运行这个程序得到一个exe类型的可执行文件,然后可以复制到c盘根目录下,用桌面左下的图标进入:开始-程序-附件-命令提示符
然后键入 cd \
到c盘根目录下输入
exe文件名 wangpin wangpin@126
就是运行这个程序
------------------------------------------------------------------
------------------------------------------------------------------
下面是一个简单的音乐程序,你可以把它加到上面代替sound()到nosound()那一部分发出<<东方红>>音乐歌曲(小心!声音可能很大)
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
int main(void)
{
int i,j;
int fr[]={392,392,440,294,262,262,220,294,392,392,
440,532,440,392,262,262,220,294,392,294,
262,247,220,196,392,294,330,294,262,262,
220,294,330,294,262,294,262,247,220,196};
int tim[]={4,2,2,8,4,2,2,8,4,4,2,2,2,2,4,2,2,8,4,
4,4,2,2,4,4,4,2,2,4,2,2,2,2,2,2,2,2,2,2,12};
for(i=0;i<40;i++)
{
sound(fr[i]);
delay(tim[i]*100000000);
nosound();
}
system("pause");
return 0;
}
C. c语言账号与密码检查的注解
摘要 编写一个密码检测程序,程序执行时,提示"Input password:“要求用户输入密码(标准密码预先设定为"hnkd2012”),然后通过字符串比较函数比较输入密码和标准密码是否相等。若相等,则显示“Congratulation!”;若不相等,则提示"Error,please input again:"重新输入,3次都不相等则提示"The program is terminated!"并终止程序的执行。要求自己编写一个字符串比较函数,而不使用系统的strcmp( )函数。
D. 用C语言程序编写用户名密码 程序
#include<stdio.h>
#include<string.h>
void main()
{
int i,flag1,flag2;
char name[20]="lushan",password[10]="123456";
char person[20],password1[10];
for(i=0;i!=3;)
{
printf("Please input the name:\n");
gets(person);
flag1=strcmp(person,name);
printf("Please input the password:\n");
gets(password1);
flag2=strcmp(password,password1);
if(flag1==0&&flag2==0)
{
printf("Pass successfully!");
break;
}
else
{
printf("You have enter the wrong name or password!\n");
i++;
}
}
}
E. c语言设计密码检测程序
#include <stdio.h>
#define UC (1U<<1) // upper case
#define LC (1U<<2) // lower case
#define NUM (1U<<3) // 0-9
#define ALL (UC|LC|NUM)
int check(const char pass1[], const char pass2[])
{
const char *p = &pass1[0];
unsigned int flag = 0;
if (strlen(pass1) < 6 || strlen(pass1) > 8)
{
printf("password length is 6 to 8.\n");
return 1;
}
if (strcmp(pass1, pass2))
{
printf("the tow passwords are diffrence.\n");
return 2;
}
while (*p)
{
if (*p >= 'a' && *p <= 'z') flag |= LC;
else if (*p >= 'A' && *p <= 'Z') flag |= UC;
else if (*p >= '0' && *p <= '9') flag |= NUM;
else
{
printf("in valid charactor: %c.\n", *p);
return 3;
}
++p;
}
if (flag == ALL) return 0;
if ((flag & UC) == 0)
{
printf("lack of uppercase.\n");
}
if ((flag & LC) == 0)
{
printf("lack of lowercase.\n");
}
if ((flag & NUM) == 0)
{
printf("lack of number.\n");
}
return -1;
}
int main(int argc, char *argv[])
{
char pass1[100];
char pass2[100];
do {
printf("input password:");
scanf("%s", pass1);
printf("repeat password:");
scanf("%s", pass2);
} while (check(pass1, pass2) != 0);
return 0;
}
F. C语言密码程序设计
手写的,没运行,你自己试一下
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
intmain()
{
char st[6];
printf("输入登陆密码: ");
gets(st);
if(strcmp(st,"123")==0)
printf("