Re: read/write at the same time



<dolatabadi.amir@xxxxxxxxx> wrote in message
news:e405e478-f8d0-4be3-97db-f9b67630280b@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I want to write a program to create prime numbers. As part of it, I
must create a file, then write prime numbers in it and also read from
to it in order to create other primes. I used a text file, but can
not have access to it simulataneously for read and write access. Reset
procedure allows me reading from it and rewrite allows me only writing
in it. How I can have permission to do both at the same time?

By not using a text file. The help file says as much: "When opening a
text file, it will be read-only" (or words to that effect). Otherwise,
it won't.

Text files have unusual semantics - they are considered to consist of
lines, separated by end-of-line sequences, and the lines are _variable_
_length_. That means that when you want to shorten a line near the
beginning, you have to move up all the text after it, or a spurious
line will be inserted. As opposed to Pascal's other type of file, the
sequence of fixed-length records, where you can change one record
without affecting all the others (but obviously not remove it, either).

Both types of files are relics from ancient times anyway.

You have the advantage that you know _where_ you will be reading and
writing. I think it should be possible to split the single file into
'pages', with a page per file, in such a manner that you only need
either read or write access to any page at one time.

Is this an exercise with given restrictions? How many primes will you
generate? How are you representing your numbers? We can tell you more
if you tell us more.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: What Are You Reading??
    ... from it reading other things; just finished Marcus du Sautoy's "The ... Music of the Primes" (popular history of mathematics). ...
    (rec.pets.cats.anecdotes)
  • Re: N-pt DFT where n != power of 2
    ... small primes of 2, 3 or 5 range. ... need) as the output time samples must respect the 960 or 120 frame size. ... Zero padding doesn't change the returned values. ... You should do a little reading (or use FFTW, reading the directions carefully and taking no steps for granted. ...
    (comp.dsp)
  • Re: Methods that count primes without counting primes or referring to them...
    ... > I've been reading over about as much stuff as I can find about prime distribution and prime counting, and I've been left with the following question. ... function for generating the number of primes less than n that doesn't ...
    (sci.math)
  • Re: Methods that count primes without counting primes or referring to them...
    ... > prime distribution and prime counting, ... > Assuming I'm understanding what I'm reading correctly (I'm getting ... > Riemann's paper on the distribution of primes provides a function for ...
    (sci.math)
  • Re: read/write at the same time
    ... procedure allows me reading from it and rewrite allows me only writing ... sequence of fixed-length records, where you can change one record ... I must have the ability to read the previously found primes (read ...
    (alt.comp.lang.borland-delphi)