#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <locale>
using namespace std;
void read_memo()
{
FILE* pfile = fopen("D:\\memo.txt", "rb");
if (!pfile) return;
fseek(pfile, 2, 0);
wchar_t buf[1024];
wstring line;
const wstring CRLF = L"\x000D\x000A";
while (!feof(pfile))
{
fgetws(buf, 1024, pfile);
line = buf;
//Trim the CRLF(ENTER+RETURN) character
if(line.find(CRLF) != wstring::npos)
line = line.substr(0, line.find(CRLF));
}
fclose(pfile);
}读取UNICODE文本到wstring
最新推荐文章于 2023-10-12 15:27:04 发布
本文介绍了一个使用C++来读取文本文件的基本示例。通过此示例,读者可以了解到如何打开一个文件、逐行读取内容并进行简单的字符串处理。此程序展示了如何去除换行符等不必要的字符。
677

被折叠的 条评论
为什么被折叠?



