From e639f1387c5ab638ac8ba9a91c60d6753d314a78 Mon Sep 17 00:00:00 2001 From: p68710245 Date: Sun, 28 Apr 2024 20:02:42 +0800 Subject: [PATCH] Delete 'copy_file_with_lines' --- copy_file_with_lines | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 copy_file_with_lines diff --git a/copy_file_with_lines b/copy_file_with_lines deleted file mode 100644 index bddc6e5..0000000 --- a/copy_file_with_lines +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -int main() -{ - std::ifstream ifile("hello.txt"); - std::ofstream ofile("hello_copy.txt"); - char temp[81]; - // 忽略文件对象判断的过程 - do - { - ifile.getline(temp, 81); - if (ifile.rdstate() == std::ios::goodbit) // 正常结束 - ofile << temp << '\n'; - else if (ifile.rdstate() == std::ios::failbit) // 读取长度超限,进入fail状态 - { - ifile.clear(); // 恢复流状态 - ofile << temp; // 注意没有换行 - } - else // 文件读取结束,进入fail+eof状态 - { - ofile << temp; - break; - } - } while (1); - ifile.close(); // 如没有这两个函数析构函数也可关闭,但建议显式书写 - ofile.close(); - return 0; -}