c - 我正在尝试使用 C 编程语言创建登录系统
问题描述
我正在尝试使用 C 编程语言创建登录系统。下面的代码是我的尝试,谁能指出我的错误。目标是匹配程序中的用户名和密码。例如,如果我输入 Amy 作为用户名和 Amy76 作为密码应该接受它并打印登录。
#include<conio.h>
#include<string.h>
int main()
{
login_session();
return 0;
}
// following function accepts the login creed for teachers
void login_session(char username[10], char password[10]){
printf("Enter instructor's Full Name :\n");
scanf("%s", &username);
printf("Enter password :\n");
scanf("%s", &password);
clrscr();
//conditional statements to test teachers username and password
if(strcmp(username, "Amy") ==0) {
if(strcmp(password,"Amy76") ==0){
printf("\nwelcome. Login Sucessfully ");
} else {
printf("\ninvalid. username and password does not exist");
}
} else if (strcmp(username, "Smith") ==0){
if(strcmp(password,"Smith345") ==0){
printf("\nwelcome. Login Sucessfully");
} else {
printf("\ninvalid.username and password does not exist");
}
} else if (strcmp(username, "Doris") ==0) {
if(strcmp(password,"Doris284") ==0){
printf("\nwelcome.Login Sucessfully");
}else {
printf("\ninvalid. username and password does not exist");
}
} else if (strcmp(username,"Wilson") == 0) {
if(strcmp(password,"Wilson809") ==0){
printf("\nwelcome.Login Sucessfully");
}else {
printf("\ninvalid. username and password does not exist");
}
}
return 0;
}
解决方案
您不能将 0 返回给返回 void 的函数。
请提及您从此代码中得到的错误。
推荐阅读
- react-native - 如何找出所有应用程序的深层链接路径?
- php - SQLSTATE[HY000]: 一般错误: 21 bad parameter or other API misuse - in pyrocms
- c# - 循环参考/保留周期
- angular - 导出 *(星号)在 Angular/Typescript 中是什么意思
- scala - 在基于 scala 的 spark 结构化流程序中执行基于 python 的模型
- python - 如何在python中保持随机生成的矩阵常数?
- javascript - 使用 momentJS 在 Jasmin 单元测试中更改时区
- c# - 比较不同机器上的字符串哈希
- c - 二维数组动态分配中的分段错误
- c# - 如何按列对数据集进行排序