Best way to convert whole file to lowercase in C

后端 未结 5 1563
死守一世寂寞
死守一世寂寞 2021-01-21 10:06

I was wondering if theres a realy good (performant) solution how to Convert a whole file to lower Case in C. I use fgetc convert the char to lower case and write it in another t

5条回答
  •  生来不讨喜
    2021-01-21 10:41

    You can usually get a little bit faster on big inputs by using fread and fwrite to read and write big chunks of the input/output. Also you should probably convert a bigger chunk (whole file if possible) into memory and then write it all at once.

    edit: I just rememberd one more thing. Sometimes programs can be faster if you select a prime number (at the very least not a power of 2) as the buffer size. I seem to recall this has to do with specifics of the cacheing mechanism.

提交回复
热议问题