[問題] fstream 中文檔案內容
遇到的問題: (題意請描述清楚)
我想要做一個內容是中文的檔案
但是使用fstream會出現不完整的內容
試著使用ios::binary模式
但是還是不行
開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux)
Dev C++
--
◤ __ \__◣ ◢◤◢◤ ψhirabbitt
◢ ◤ ◢███◣ ◢███◣
和妳的約定 █████ █████ 不變心的約定
██●█● █▇███
是變心的約定 ██╱╲ ●◥█████◣● 是我和自己的約定
◥╱█╱╱ ● ◥████ ˇ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.13.127.91
推
03/01 17:12, , 1F
03/01 17:12, 1F
#include <fstream>
#include <iostream>
using namespace std;
int main(){
ifstream in_stream;
char* f,s,t;
in_stream.open("file.039");
if (in_stream.fail())
{
cout << "開啟檔案失敗!\n";
}else{
in_stream >> f >> s >> t;
cout << f << s << t;
in_stream.close();
system("pause");
}
ofstream out_stream;
cin >> f >> s >> t;
out_stream.open("file.039",ios::binary);
out_stream << f <<" "<< s <<" "<< t <<" " ;
out_stream.close();
system("pause");
return 0;
}
※ 編輯: hirabbitt 來自: 163.13.127.91 (03/01 17:42)
→
03/01 17:44, , 2F
03/01 17:44, 2F
→
03/01 17:45, , 3F
03/01 17:45, 3F
→
03/01 18:17, , 4F
03/01 18:17, 4F
→
03/01 18:17, , 5F
03/01 18:17, 5F
→
03/01 18:17, , 6F
03/01 18:17, 6F
推
03/01 18:31, , 7F
03/01 18:31, 7F
→
03/01 18:33, , 8F
03/01 18:33, 8F
→
03/01 18:36, , 9F
03/01 18:36, 9F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章