用fstream打开文件后,如何转到文件尾部? 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道文件长度的情况 怎么seek啊! fstream继承自iostream,iostream的basic_istream Members中有seekg方法,msdn说:Moves the read position in a streamExample// basic_istream_seekg.cpp// compile with: /EHsc#include <iostream>#include <fstream>int main ( ) { using namespace std; ifstream file; char c, c1; file.open( "basic_istream_seekg.txt" ); file.seekg(2); // chars to skip file >> c; cout << c << endl; file.seekg( 0, ios_base::beg ); file >> c; cout << c << endl; file.seekg( -1, ios_base::end ); file >> c1; cout << c1 << endl;} C++在对应所需名称或序数的集合中,未找到项目 用Dll来实现灵活升级的问题? 关于VC一个很菜的问题???? 与QQ类似的加密存储数据再解析的方法如何实现? CListCtrl 创建问题! leakdiag那个symbol search path应该怎么设置 mfc CHotKeyCtrl控件字体颜色修改 ATL里如何将DWORD转黄成char* 有什么方法可以看出一个activex控件里面方法格式? 一个顶层的对话框怎么激活另一个非模态的对话框? 郁闷,希望大虾指导!! recv()不在等待时候的问题
// basic_istream_seekg.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>int main ( )
{
using namespace std;
ifstream file;
char c, c1; file.open( "basic_istream_seekg.txt" );
file.seekg(2); // chars to skip
file >> c;
cout << c << endl; file.seekg( 0, ios_base::beg );
file >> c;
cout << c << endl; file.seekg( -1, ios_base::end );
file >> c1;
cout << c1 << endl;
}