Tuesday, 3 September 2013

can't update file records with this function

can't update file records with this function

Ok so i got this function that suppose to update record in this file below
the first line tells the number of entries and this member function is
suppose to modify it it with the agrs
void fman::update(ul ln_num, const char* str)
{
//ul is a typedef for unsigned int, fio is fstream error_check works
//corretly
if (!error_check(fio))
return;
fio.seekg(0, std::ios_base::beg);
fio>>_ln_num_w;
eatline(fio);
if (ln_num > _ln_num_w || ln_num < 0)
{
std::cout<<"\nline number exceddes the number of lines";
return;
}
ul i = 0;
while (true)
{
if (i == ln_num){break;}
eatline(fio);
fio.get();
fio>>i;
}
fio.get();
fio.get();
for (ul j = 0;j < strlen(str);j++)
{
fio<<str[j];
if (fio.get() == ')')
break;
}
}
here is eatline
void fman::eatline(std::fstream &_fio)
{
while (_fio.get() != '\n')
continue;
}
update doesnt even modify the file.

No comments:

Post a Comment