📄 filereverse.cpp
字号:
// FileReverse.cpp
#include <iomanip>
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
#include <fstream>
using std::fstream;
using std::ios;
char* FileNameIn = "Original.txt";
char* FileNameOut = "Reversed.txt";
// ---主程式------------------------
int main()
{
long CharNum, Offset;
char Ch;
fstream FileInput(FileNameIn, ios::in);
if (!FileInput)
{cout << "档案 " << FileNameIn
<< " 开启失败!" << endl; exit(1);}
fstream FileOutput(FileNameOut, ios::out);
if (!FileOutput)
{cout << "档案 " << FileNameOut
<< " 存档失败!" << endl; exit(1);}
cout << "档案 " << FileNameIn
<< " 开启成功" << endl;
FileInput.seekg(0L, ios::end); //移到档案结束的地方
CharNum = FileInput.tellg(); //获得字元数目
for (Offset=1L; Offset<= CharNum; Offset++)
{
FileInput.seekg(-Offset, ios::end);
Ch = FileInput.get();
FileOutput << Ch;
}
FileOutput.close();
FileInput.close();
cout << "倒转档案 " << FileNameIn
<< " 后的内容\n成功存于档案 "
<< FileNameOut
<< " 内." << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -