aagc
asked on
Weird problem working with text files,can some one help?
ok, 1st thnx for read me.
the following is how the proggy read the file
fstream database;
database.open(filename,ios ::in | ios::out);
while (!database.eof())
{
database.getline(persona[c ont].nombr e,60,'\n') ;
if(strlen(persona[cont].no mbre)==0) {cont=0;break;}
database.getline(persona[c ont].telef ono,20,'\n ');
database.getline(persona[c ont].ciuda d,30,'\n') ;
database.getline(persona[c ont].edad, 10,'\n');
cont++;
}
database.close();
then this is how i save the file....
cont=0;
database.open(filename,ios ::out);
database.seekg (0, ios::beg);
for(;cont<max;cont++)
{
database << persona[cont].nombre <<endl;
database << persona[cont].telefono <<endl;
database << persona[cont].ciudad << endl;
database << persona[cont].edad <<endl;
}
database.close();
well all that works fine when the proggy runs the 1st and 2nd time... but at the 3er time the file just get deleted well not deleted but all the data inside is missing :(...
i really need help.
Thnx again u guys.
the following is how the proggy read the file
fstream database;
database.open(filename,ios
while (!database.eof())
{
database.getline(persona[c
if(strlen(persona[cont].no
database.getline(persona[c
database.getline(persona[c
database.getline(persona[c
cont++;
}
database.close();
then this is how i save the file....
cont=0;
database.open(filename,ios
database.seekg (0, ios::beg);
for(;cont<max;cont++)
{
database << persona[cont].nombre <<endl;
database << persona[cont].telefono <<endl;
database << persona[cont].ciudad << endl;
database << persona[cont].edad <<endl;
}
database.close();
well all that works fine when the proggy runs the 1st and 2nd time... but at the 3er time the file just get deleted well not deleted but all the data inside is missing :(...
i really need help.
Thnx again u guys.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: dpearson
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer