Best way to convert whole file to lowercase in C

后端 未结 5 1565
死守一世寂寞
死守一世寂寞 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:30

    I'd say you've hit the nail on the head. Temp file means that you don't delete the original until you're sure that you're done processing it which means upon error the original remains. I'd say that's the correct way of doing it.

    As suggested by another answer (if file size permits) you can do a memory mapping of the file via the mmap function and have it readily available in memory (no real performance difference if the file is less than the size of a page as it's probably going to get read into memory once you do the first read anyway)

提交回复
热议问题