can't update file records with this function

Ok so i got this function that suppose to update record in this file below
1
2
3
4
2
[1](foo)
[2](bar)
[3](foobar)


the first line tells the number of entries and this member function is suppose to modify it it with the agrs
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
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
1
2
3
4
5
void fman::eatline(std::fstream &_fio)
{
	while (_fio.get() != '\n')
		continue;
}

update doesnt even modify the file.
Topic archived. No new replies allowed.