hi friends,

I am having a problem with IO operations in C++.

This is the path:
-----------------
C:\Symbian\9.1\S60_3rd_MR\Epoc32\winscw\c\system\Apps\test\

I am having 4 files say f1.txt (size 400 KB)
f2.txt (1 kb)
f3.txt (1 kb)
f4.txt (1 kb)

These four files reside in the following above given path.
The files in the program are opened in binary mode.

a) In the first case, I am reading the entire file (f1.txt)
in a loop (it contains say 10000 records) i.e there are 10000 read operations
(*) After that if i try to open files [f2.txt,f2.txt and f4.txt]
it doesnt get opened even if they exists.

b) In the second case, I am not reading te entire file but just
1000 records i.e there are just 1000 read operations.

In this case all the files i.e [f2.txt,f3.txt,f4.txt] are created.

why is it that after 10000 read operations code doesnt work properly
and after 1000 operations it works properly.

Is there any limitation on the number of read operations or do i need any privilage for such extensive file operation.

In both the cases the program doesnt crash it exits normally.

I am in a reall fix. please do help me out.
Eagerly waiting for your reply.

Thanks,
himanshu k.
Symbian Application Developer

hi ivailosp,

The streams have been defined as class members.

[in .h]

class A
{
fstream file1;
fstream file2;
};

[.cpp]

A()
{
file1.open();
file1.read()
....
...
..
.
file2.open();
}

~A()
{
file1.close();
file2.close();
}

Thanks,
himanshu k.
Symbian Application Developer.

im not sure bu can you try this:
[in .h]

class A
{
fstream* file1;
fstream* file2;
};

[.cpp]

A()
{
file1 = new fstream;
file2 = new fstream;
file1->open();
file1->read()
....
...
..
.
file2->open();
}

~A()
{
file1->close();
file2->close();
delete file1;
delete file2;
}

hm try to close file1 before open file2 or try to use only one fstream and open file work with it and close it, and use same fstream to open second and etc.

We need to see actual code. I suspect the problem is actually somewhere else in your program, quite possibly trashing memory somewhere during the first file read operation, or failing to delete memory when necessary making your program gobble up all the computers resources.

Look at Task Manager while your program is running and see if the memory used by your program or other resources keeps increasing.

This article has been dead for over six months. Start a new discussion instead.