ios::ate places the get-position pointer at the file end, enable tellg() to return the size of the f
来源:互联网 发布:淘宝情趣用品店名大全 编辑:程序博客网 时间:2024/05/17 09:19
#include <fstream>#include <iostream>#include <cstdlib>using namespace std;void print_error(const char* p1, const char* p2 = 0);int main(int argc, char* argv[]){ if (3 != argc) print_error("usage: function input_file output_file"); ifstream in(argv[1], ios::binary | ios::ate); if (!in) print_error("cannot open input file", argv[1]); long N = in.tellg(); char buffer[N]; in.seekg(ios::beg); ofstream out(argv[2], ios::binary); if (!out) print_error("cannot open output file", argv[2]); in.read(buffer, N); out.write(buffer, N); if (!in.good()) { print_error("something strange happened"); exit(1); } in.close(); out.close(); return 0;}void print_error(const char* p1, const char* p2) { if (p2) cerr << p1 << ' ' << p2 << endl; else cerr << p1 << endl; exit(1);}
- ios::ate places the get-position pointer at the file end, enable tellg() to return the size of the f
- Linux - How to remove the new line at the end of file when using vim
- by the end of, at the end of , in the end , to the end 的区别与用法
- Appending to the End of a File
- 【Hackerrank】Get the value of the node at a specific position from the tail
- warning no newline at the end of file
- warning: no newline at the end of file
- warning no newline at the end of file
- error:warning no newline at the end of file
- warning no newline at the end of file
- warning: no newline at the end of file
- warning no newline at the end of file
- warning no newline at the end of file
- warning no newline at the end of file
- before we get to the end of our block
- XML文件要有根标签(Extra content at the end of the document in file 错误
- A pointer to an object & A pointer one past the end of a different object
- How to enter an End-Of-File from the keyboard
- 贝塞尔曲线的数学原理
- While it is not the end of a file, output file line by line
- c++五十条
- Error:The system has not been taken off maintenance mode completely.
- #pragma once及其他
- ios::ate places the get-position pointer at the file end, enable tellg() to return the size of the f
- Android 2.3 SD卡挂载流程浅析
- 2012 Multi-University Training Contest 3
- ogre SdkTray
- Smoke(人人)
- Android apk反编译心得
- Windows Store apps开发[5]导航栏(AppBar)的使用
- 字符串相似度算法
- 雨落无痕(人人)