【发布时间】:2015-10-03 13:59:30
【问题描述】:
C 密码功能不起作用。我不知道出了什么问题。任何人都可以帮忙吗?
Error: Incomplete universal character \u
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
void userLog(int attempt, char user_name[], char user_pass[]);
void checkUserLog(int attempt, char user_name[], char user_pass[]);
int main()
{
system("color 1F"); //change UI background to blue and text to white
int *pos = 0;
int attempt = 0;
int low, high, *temp_pos;
char searchKey[50], *is_found[200];
char user_name[6], user_pass[12];
//printf("print main's test\n\n");
userLog(attempt, user_name, user_pass);
//libraryBookMainMenu(searchKey[50], low, high, &is_found[200], &temp_pos);
//systemMainMenu();
fflush(stdin);
getch();
}
void userLog(int attempt, char user_name[], char user_pass[])
{
system("cls");
if (attempt == 0) {
printf("Access is Denied!!!");
Sleep(1500);
attempt = 3; //done to reset attempts for user login
exit(2);
}
attempt--;
printf("\n\n Enter your username: ");
fflush(stdin); // done to clear last input after the while statement is not true
scanf("%s", &user_name);
printf("\n\n Enter your password: ");
fflush(stdin); // done to clear last input after the while statement is not true
checkUserLog(attempt, user_name, user_pass);
}
void checkUserLog(int attempt, char user_name[], char user_pass[])
{
int i = 0;
char get_char;
char default_user[] = "admin";
char default_pass[] = "adminpass00";
while (i < 10) {
get_char = getch();
if (get_char == 13) {
break; //ASCII value for enter
}
if (get_char == 8) {
putch('\b'); //escape sequence for backspace
putch(' '); //puts an empty space as you backspace
putch('\b'); //return blinking cursor to original position
i--;
continue; //without this backspace won't work
}
user_pass[i] = get_char;
printf("*");
i++;
}
user_pass[i] = '\0';
/*while (strcmp(user_name,default_user)!= 0 || strcmp(user_pass,default_pass) != 0) {
printf("\n Incorrect password\username\n\n\t %d more attempts remaining", attempt);
Sleep(1500);
userLog(attempt, user_name, user_pass);
}*/
attempt = 3;
//libraryBookMainMenu(bookLibrary, searchKey[50], low, high, &pos, &temp_pos);
}
【问题讨论】:
-
报错信息明明跟passwd函数没有关系,那你的问题是为什么呢?并发布实际失败的代码——这不会,因为你已经注释掉了错误的代码——并在错误消息中包含行号和/或在你发布的代码中清楚地标记有问题的行。跨度>