Need help with datafiles !

I was writing a program for validating username and password from a datafile. However, the program stops working as soon as I press enter after entering the password. Please tell me where I am wrong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<dos.h>
#include<time.h>
#include<string.h>
void main()

{
//Initialize
int i = 0;
char k;
char username[20],vusername[20],vpassword[20],password[20];
int flag = 0;
gets(username);

//Input the password and show "*'s

while((k = getch())!=13 )
  {

  password[i] = k;
  cout << "*";
  i++;

  }
//Open data files
ifstream fin;
fin.open("accuser.dat");
ifstream fin1;
fin1.open("accpass.dat");

//Verification

while(!fin.eof()&&!fin1.eof())
    {
      fin.get(vusername,20,'$');
      fin1.get(vpassword,20,'$');
      if(strcmp(vusername,username)&&strcmp(vpassword,password))
      {
        flag = 1;
      }
    }
if(flag == 1)
 {
  cout<<"sucess ! ";
 }

else

 {
  cout<<"not yet ... ";
 }
}
}
Last edited on
Topic archived. No new replies allowed.