C语言编写一个用户登陆的程序?

C语言编写一个用户登陆的程序?,第1张

代码如下:

#include<stdio.h>

#pragma warning(disable:4996)

#include<string.h>

int main()

{

int i = 0

char password[10] = { 0 }

printf("请输入密码:")

while (i <3)

{

scanf("%s", password)

printf("\n")

if (strcmp(password, "972816") == 0)

{

printf("登录成功\n")

break

}

else

{

i++

if (i != 3)

printf("再输入一次")

}

}

if (i == 3)

printf("密码错误三次退出登录界面\n")

system("pause")

return 0

扩展资料:

#include后面有两种方式,<>;和""前者先在标准库中查找,查找不到在path中查找。后者为文件路径,若直接是文件名则在项目根目录下查找。

引用方法:#include <stdio.h>

注意事项:在TC2.0中,允许不引用此头文件而直接调用其中的函数,但这种做法是不标准的。也不建议这样做。以避免出现在其他IDE中无法编译或执行的问题。

参考资料来源:百度百科—include

参考资料来源:百度百科—stdio.h

void student::print()

{

char s[10]

int i=0

string password="guest"

cout<<endl<<endl<<endl

cout<<"\t\t**************************************\n"

cout<<"\t\t***** 学生信息管理系统 *****\n"

cout<<"\t\t**************************************\n"

cout<<"\t\t请输入密码(7位数):"

s[0]=getch()

while(s[i]!='\r') //输入回车键停止

{

cout<<"*"

s[++i]=getch()

}

s[i]='\0'

cout<<endl

if(s==password)

cout<<"\t\t欢迎使用学生信息管理系统!\n"

else

{

cout<<"\t\t您输入的密码有误!无权使用\n"

exit(0)

}

system("cls")

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11486223.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存