Reading from a changing file?

N

Neo

Hi,
I need to read data from a file whose contents keeps changing
regularly, is there any method of doing it without closing and opening
repeatedly?

Thanks,
Neo
 
G

Gianni Mariani

Neo said:
Hi,
I need to read data from a file whose contents keeps changing
regularly, is there any method of doing it without closing and opening
repeatedly?

Use the OS specific read methods or memory map the file.

Off topic for comp.lang.c++
 
G

Gianni Mariani

Neo said:
Not off topic as I need to do that in a c++ program.

Under that logic, everything is on-topic. You're going to get the best
help in a operating system specific NG.
 
J

James Kanze

Use the OS specific read methods or memory map the file.
Off topic for comp.lang.c++
[/QUOTE]
Not off topic as I need to do that in a c++ program.

He means that any viable answers would be off topic, not that
the question was. There's no way to do this in pure, portable
C++ that is guaranteed to work (which you probably didn't know
before asking). The problem is that once the filebuf has seen
EOF, it may (and probably does) remember this fact, and you have
no way of clearing this status. You also have no way of
reliably turning off buffering for input. (The way stream input
works, you really need at least a one character buffer anyway.)

The result is that you'll need to use some platform dependant
functions, and those are off topic here. Independantly of any
considerations of politness or respect for the groups charter,
you'll probably get faster and better answers in a platform
oriented group.
 
R

red floyd

Neo said:
Not off topic as I need to do that in a c++ program.

The best way to determine on/off topic is to ask the following two
questions:

1. Would the answer be essentially the same if I was implementing in
another language? If so, then your question belongs in either a
platform specific newsgroup or a general programming newsgroup.

2. Does the question make sense if I change the platform? i.e. go from
Windows to Linux (or vice versa). If not, then ask in a newsgroup
dedicated to your platform.

If you answer "no" to the first, and "yes" to the second, odds are that
you're on topic.

In your particular case, however, the answer to the first question is
"yes", so you're not on-topic in c.l.c++.

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top