我正在尝试用流编写一些简单的代码但是指令读取挂起。为什么? 如果将char的定义从char32_t更改为wchar_t,那么它有效吗? (记得创建文件xxx.txt并写一些东西)。应该是这样吗?
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <wchar.h>
#include <locale>
#include <stdlib.h>
#include <uchar.h>
// compilation with -std=c++11
using namespace std;
int main(int argc, char **argv)
{
typedef char32_t Char; // attention at Capital C
// typedef wchar_t Char; // attention at Capital C
typedef basic_ifstream <Char> ifStream; // attention at capital S
ifStream f("xxx.txt", ios::in); // the file exists and contains some text
if(f){
// f.imbue(locale(setlocale(LC_ALL,"")));
Char a[0x100];
f.read(a,14);
f.close();
cout<<"fileClosed"<<endl;
}
return 0;
}