标题:utf-8文件流的seekg(--)
只看楼主
kyfi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-4-18
 问题点数:0 回复次数:0 
utf-8文件流的seekg(--)
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
    string s;
    char c;
    ifstream fin("2.htm");//这是一个utf-8编码的htm文件
    if (fin.fail())
    {
        cout << "alsdj";
        exit(0);
    }
    cout<<fin.get();
    //fin.seekg(-1, ios::cur);  //没有这一步运行正常,加上这一步后,之后get()到的都是255.
    for (int i = 0; i < 10; i++)
    {
        c = fin.get();
        cout << c;
    }

}
搜索更多相关主题的帖子: include 
2016-04-18 22:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-463813-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.252319 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved