1

Topic: Fast reading from a file and fast file recording

Interesting, what methods of fast reading of lines from the text file and fast record of lines in text a file exist? Functions fscanf, fgets, fprintf for this purpose approach or it is better to use any other methods? Whether there are in library MFC such methods? (It is a question of a case when it is necessary to count from a file of 50 thousand lines or to write down in a file of 50 thousand lines).

2

Re: Fast reading from a file and fast file recording

Hello, RussianFellow, you wrote: memory-mapped files Further.

3

Re: Fast reading from a file and fast file recording

Hello, RussianFellow, you wrote: RF> Functions fscanf, fgets, fprintf for this purpose approach or it is better to use any other methods? Whether there are in library MFC such methods? Type function fscanf and fgets generally has not enough for what approach, except  hand-made articles. What will your program if in the text file "casually" there was a line long 4 kilobytes do? What size there should be a buffer for fgets' to consider, what any not "the beaten" file will be read correctly? What as much as possible admissible it is long lines in a correct "text" file and how the program if this limit is exceeded should behave? Type functions fread in a combination to manual sharing for the lines can work very much even not bad, but it depends on implementation. In one implementations they automatically use memory mapped files, in others essential acceleration can achieve, delivering the big buffer (see setvbuf) or simply reading in the big buffer. fprintf is a function  an output and if it is necessary to you, without it it is difficult to manage. But if to you it is not necessary  an output, it is better to use fwrite, fputs at the worst. With big enough buffer it can work not bad. RF> (it is a question of a case when it is necessary to count from a file of 50 thousand lines or to write down in a file of 50 thousand lines). For what time he should be read? It is not eliminated that on the modern iron it is read quickly enough even if all to do as much as possible in a simple way.

4

Re: Fast reading from a file and fast file recording

Hello, Amon_RA, you wrote: A_R> Hello, RussianFellow, you wrote: A_R> memory-mapped files A_R> Further itself. I will throw still the help (actually a synonym of about what it is specified above) - Shared Memory

5

Re: Fast reading from a file and fast file recording

Hello, Pzz, you wrote: RF>> (It is a question of a case when it is necessary to count from a file of 50 thousand lines or to write down in a file of 50 thousand lines). Pzz> For what time he should be read? It is not eliminated that on the modern iron it is read quickly enough even if all to do as much as possible in a simple way. For some seconds (for example, for 5 seconds, a maximum - for 10 seconds).

6

Re: Fast reading from a file and fast file recording

Hello, RussianFellow, you wrote: Pzz>> For what time he should be read? It is not eliminated that on the modern iron it is read quickly enough even if all to do as much as possible in a simple way. RF> for some seconds (for example, for 5 seconds, a maximum - for 10 seconds). I would try, but it seems to me, this very big time, and the code written without any shifts, will be easy to be laid down at this time.

7

Re: Fast reading from a file and fast file recording

Hello, Amon_RA, you wrote: A_R> memory-mapped files Here the class-wrapper for operation with MMF somewhere rolled. And here https://rsdn.org/article/files/Classes/filemap.xml the Author (: Vitaly Brusentsev Data: 11/12/2001 Class CFileMap simplifies operation with the files projected in storage (memory-mapped files).

8

Re: Fast reading from a file and fast file recording

And still a question: for data reading from a line there is a function sscanf. Whether there are still any functions of data reading from lines, and if yes, what?

9

Re: Fast reading from a file and fast file recording

Hello, RussianFellow, you wrote: RF> And still a question: for data reading from a line there is a function sscanf. Whether RF> There are still any functions of data reading from lines, and if yes, what? Did not understand a question. What means, data reading from lines, and than it differs from data reading from a line?

10

Re: Fast reading from a file and fast file recording

Hello, Pzz, you wrote: Pzz> Hello, RussianFellow, you wrote: RF>> And still a question: for data reading from a line there is a function sscanf. Whether RF>> There are still any functions of data reading from lines, and if yes, what? Pzz> did not understand a question. What means, data reading from lines, and than it differs from data reading from a line? Well that is there is the long line containing words or numbers, divided by gaps. Also this lines there are '\n ' characters. This line is completed by '\0 ' character. How to count these words and numbers from this line? Whether only by means of function sscanf or it is possible somehow in another way?

11

Re: Fast reading from a file and fast file recording

Hello, RussianFellow, you wrote: RF> Well that is there is the long line containing words or numbers, divided by gaps. Also this lines there are '\n ' characters. This line is completed by '\0 ' character. RF> How to count these words and numbers from this line? Whether only by means of function sscanf or it is possible somehow in another way? Well, sscanf' all the same, there are there characters of the end of lines, or not. In the sense that he considers them . But I nevertheless would write a parcer. At least already to receive distinct diagnostics at errors.