Fstream fails to create new file

前端 未结 6 1050
梦如初夏
梦如初夏 2021-01-12 22:57

I\'m using a FileManager for a project so that reading and writing is less of a hassle for me. Or would be, if I didn\'t spend all this time debugging it. So, this comfort-c

6条回答
  •  天涯浪人
    2021-01-12 23:51

    You cannot use std::ios::in on a non-existing file. Use

    std::ios::in | std::ios::out | std::ios::trunc
    

    instead (but make sure it doesn't exist or it will be truncated to zero bytes).

提交回复
热议问题