-3
當我試圖從Login方法調用ShowMeMine(struct user_node userob)時,如果條件那麼它即使密碼正確也說我錯了passwrod。這是登錄成功,如果我從這裏刪除條件如果condition.enter代碼 我將該文件保存爲.h擴展名。來自if codition的調用方法導致其他部分
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct user_node{
char username[20];
char password[100];
char address[200];
int age;
int unique_id; //It will help in connecting user_node and his bill
};
struct bill{
long user_bill_no;
int show_this_bill;
long meter_no;
double total_amount;
int unique_id;
};
//viewing specific person
void ShowMeMine(struct user_node userob){
printf("");
}
//Login authentication check
void Login(struct user_node userob){
FILE *fpread;
fpread=fopen("userdata.DAT","rb+");
char key[100];
char user_name[40],password[100];
char choice,ch;
int x;
int pass_count=0;
printf("Enter your name");
gets(user_name);
while((ch=getch())!='.'){
password[pass_count++]=ch;
printf("*");
}
while(fread(&userob,sizeof(userob),1,fpread)==1){
if(stricmp(user_name,userob.username)==0){
strcpy(key,userob.password);
userob=userob;
break;
}
}
if(strcmp(key,password)==0){
printf("Sucessfully Logged In");
ShowMeMine(userob);
}
else printf("Login Unsuccessful ");
printf("%d",x);
}
[不要使用'gets()',這是danegerous](http://stackoverflow.com/q/1694036/2173917)。改用['fgets()'](https://linux.die.net/man/3/fgets)。 –
***請刪除代碼中的粗魯/辱罵性評論(打印聲明),這可能對您很有趣,但許多人會發現這種不敬。*** –
非常抱歉。 這只是一個錯誤。 @SouravGhosh –