login and register

hi.. im working on a school project .. its a very simple program but i wish to make a 'register and login' part to this program..but i gt stuck in this process...i was hoping u guys could help me out here..these are two of the functions related to the register and login part..would any mind to debugg it..
could be very helpful..

here username is a class and im trying to pass it as argument in the login function but it isnt working..

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
void create(){
char ch[20],chh[20];
char g='y';
fstream f("sethu.dat",ios::out);
while(1){
username s;
s.get();
f.write((char*)&s,sizeof(s));
cout<<"\nwould yoy like to create a new account?";
cin>>g;
if(g=='n')
{
break;
}}
}
int check(char f[20],username e)
{
     char i[20];
     strcpy(e.red(),i);
     if (stricmp(i,f)==0)
     return 0;
     else
     return 1;
}



void Login(){
fstream h("sethu.dat",ios::in|ios::binary);
char f[20],g[6];
username e;
cout<<"\n username:";
gets(f);
while(h.read((char*)&e,sizeof(e))){
	   if (check(f[20],username *e)=0)
	   cout<<"\nenter your password";
	   break;
		}  }

A listing of your class declaration would have been helpful.

but it isn't working..

What does that mean? Compile errors? run time errors? bad results? Please be specific.
Since you haven't posted you entire program, we can't compile and run it.

Some obvious problems:
Line 19: The source of the strcpy is an uninitialized array (i).
Line 19: What does e.red() return? This is the destination of the strcpy. I doubt you meant to use a function call here.
Line 20: Again, i is an uninitialized array.
Line 34: You're reading into the base address of the username instance. This is a bad practice. This assumes guilty knowledge of how username is laid out. username should have a read function that knows how to populate itself.
Line 35: Remove username *
Last edited on
im soo sorry fr this post...i posted this without checking my program once again..but nw i have figured it out..
again sorry fr this...
anyway thanks for the reply
Topic archived. No new replies allowed.