how to open many files simultaneously for reading in c
Posted
by monkeyking
on Stack Overflow
See other posts from Stack Overflow
or by monkeyking
Published on 2010-04-01T10:25:56Z
Indexed on
2010/04/01
10:33 UTC
Read the original article
Hit count: 253
I'm trying to port some of my c++ code into c. I have the following construct
class reader{
private:
FILE *fp;
alot_of_data data;//updated by read_until() method
public:
reader(const char*filename)
read_until(some conditional dependent on the contents of the file, and the arg supplied)
}
Im then instantiating hundreds of these object and iterate over them using several 'read_until()' for each file until allfiles is at eof.
I'm failing to see any clever way to do this in c, the only solution I can come up with is making an array of FILE pointers, and do the same with all the private member data from my class.
But this seems very messy, can I implement the functionality of my class as a function pointer, or anything better, I think I'm missing a fundamental design pattern?
The files are way to big to have all in memory, so reading everything from every file is not feasible Thanks
© Stack Overflow or respective owner