problem regarding files

i am working on my c++ school project. i have a problem in that.
i have a class with 3 char data members. while writing to a file, the first 2 are written and the third one is not. why? and how do i correct that?
Ps: i have my board practical exam coming up this month. i have to submit mine by next week. and the this part happens to be the entry to the whole program. please help

code:
fstream f;int i;
f.open("users",ios::app|ios::binary);
cout<<"Enter name : ";
gets(name);
cout<<"Enter username: ";
gets(uname);
cout<<"Enter Password: ";
while((pass[i]=getch())!=13)
{
if(pass[i]==8)
{
cout<<"\b";
i=i-1;
}
else
{
cout<<'*';
i++;
}
}
if(pass[i]==13)
{
pass[i]='\0';
}

strcpy(s.name,name);
strcpy(s.username,uname);
strcpy(s.password,pass);
f.write((char*)&s,sizeof(s));
f<<endl;
Last edited on
i have a class with 3 char data members. while writing to a file, the first 2 are written and the third one is not. why?

Sometimes my car stops running. Why?

You haven't provided enough information for any sort of educated guess.
The clairvoyants are off duty now.
Can you show the code so that ordinary programmers can have a look?
Topic archived. No new replies allowed.