Remove file in C++ under UNIX

前端 未结 5 942
悲&欢浪女
悲&欢浪女 2021-02-07 00:46

How do you guys typically delete files on Linux OS? I am thinking of using the unlink function call, but I wonder if you have a better idea, as the C++ standard has

5条回答
  •  遥遥无期
    2021-02-07 01:15

    The Standard includes a function called remove which does that. Though i would prefer boost.filesystem for that (if i already use boost anyway).

    #include 
    
    int main() {
        std::remove("/home/js/file.txt");
    }
    

提交回复
热议问题