'optimal way to read chunks of a file while searching for a delimiter in c++?
I want to split a file into several new files depending on the number of new line characters there are. Currently, I only read byte by byte looking for the newline character at each read. My issue is that I feel that my method is too slow. I do not want to call any functions. Is there a rule that I should follow in regards to how big of a chunk at each read call I should be doing?
I was thinking that maybe I should read in chunks and then iterate over each chunk looking for the newline character and setting the cursor to just after that newline character. Though, I am not sure as to how this may save me time in terms of runtime. Is reading byte by byte using the read call gonna take longer than me iterating over each chunk?
Also, are there differences between IO libraries? I've heard of how IO streams work, but don't see how that may be better than the IO system call libraries from C.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
