File issues in in C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 7
Reputation: himsymcpp is an unknown quantity at this point 
Solved Threads: 0
himsymcpp himsymcpp is offline Offline
Newbie Poster

File issues in in C++

 
0
  #1
Jul 3rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 129
Reputation: ivailosp is an unknown quantity at this point 
Solved Threads: 22
ivailosp ivailosp is offline Offline
Junior Poster

Re: File issues in in C++

 
0
  #2
Jul 3rd, 2008
how you open this files. did you close f1... and then open f2
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 130
Reputation: Q8iEnG is an unknown quantity at this point 
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster

Re: File issues in in C++

 
0
  #3
Jul 3rd, 2008
Can you put your code? to see where's the problem
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 7
Reputation: himsymcpp is an unknown quantity at this point 
Solved Threads: 0
himsymcpp himsymcpp is offline Offline
Newbie Poster

Re: File issues in in C++

 
0
  #4
Jul 3rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 129
Reputation: ivailosp is an unknown quantity at this point 
Solved Threads: 22
ivailosp ivailosp is offline Offline
Junior Poster

Re: File issues in in C++

 
0
  #5
Jul 3rd, 2008
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;
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 7
Reputation: himsymcpp is an unknown quantity at this point 
Solved Threads: 0
himsymcpp himsymcpp is offline Offline
Newbie Poster

Re: File issues in in C++

 
0
  #6
Jul 3rd, 2008
hi ivailosp,

I tried it but didn't work.

thanks
himanshu k
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 129
Reputation: ivailosp is an unknown quantity at this point 
Solved Threads: 22
ivailosp ivailosp is offline Offline
Junior Poster

Re: File issues in in C++

 
0
  #7
Jul 3rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: File issues in in C++

 
0
  #8
Jul 3rd, 2008
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.
Last edited by Ancient Dragon; Jul 3rd, 2008 at 9:16 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC