Rename a file: Difference between revisions
Content added Content deleted
Line 84: | Line 84: | ||
int main() |
int main() |
||
{ |
{ |
||
std::rename("input.txt", "output.txt"); |
std::rename("input.txt", "output.txt"); |
||
std::rename("docs", "mydocs"); |
std::rename("docs", "mydocs"); |
||
std::rename("/input.txt", "/output.txt"); |
std::rename("/input.txt", "/output.txt"); |
||
std::rename("/docs", "/mydocs"); |
std::rename("/docs", "/mydocs"); |
||
return 0; |
|||
}</lang> |
|||
{{libheader|Boost}} |
|||
compiled with g++ -lboost_system -lboost_filesystem |
|||
<lang cpp>#include "boost/filesystem.hpp" |
|||
int main() |
|||
{ |
|||
boost::filesystem::rename( |
|||
boost::filesystem::path("input.txt"), |
|||
boost::filesystem::path("output.txt")); |
|||
boost::filesystem::rename( |
|||
boost::filesystem::path("docs"), |
|||
boost::filesystem::path("mydocs")); |
|||
boost::filesystem::rename( |
|||
boost::filesystem::path("/input.txt"), |
|||
boost::filesystem::path("/output.txt")); |
|||
boost::filesystem::rename( |
|||
boost::filesystem::path("/docs"), |
|||
boost::filesystem::path("/mydocs"));*/ |
|||
return 0; |
|||
}</lang> |
}</lang> |
||