getline while reading a file vs reading whole file and then splitting based on newline character

后端 未结 6 1391
孤街浪徒
孤街浪徒 2020-12-16 17:09

I want to process each line of a file on a hard-disk now. Is it better to load a file as a whole and then split on basis of newline character (using boost), or is it better

6条回答
  •  执念已碎
    2020-12-16 17:33

    If it's a small file on disk, it's probably more efficient to read the entire file and parse it line by line vs. reading one line at a time--that would take lot's of disk access.

提交回复
热议问题