如何阅读包含非英语字符串的txt文件?获取字符串后,我会将其存储在链接列表中,因此它也应该适合存储在节点中,然后打印出来。
当我尝试从下面的.txt文件代码中获取字符串“türkçe”时,它的输出为:
输出:tⁿrkτe
**word.txt**
türkçe
<string>
<iostream>
<fstream>
int main() {
fstream inputFile;
inputFile.open(word.txt);
string line;
getline(inputFile,line);
cout << line << endl;
return 0;
}
答案 0 :(得分:0)
问题的解决方案:
#include <string>
#include <iostream>
#include <fstream>
#include <locale.h>
using namespace std;
int main() {
setlocale(LC_ALL, "turkish");
fstream inputFile;
inputFile.open("word.txt");
string line;
getline(inputFile,line);
cout << line << endl;
return 0;
}