mình ghi file với chế độ bin
không hiểu thế nào mà nó lại thành file text nhỉ, có thể mở bằng notepad và đọc được các kí tự ascii
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void ghi(string, char );
int main(){
int songuyen = 1;
float sothuc = 2.2;
char kitu = 'q';
ghi("output.dat", kitu);
system("pause");
return 0;
}
void ghi(string name, char kitu){
ofstream ghi(name, ios::binary);
ghi.write(&kitu, sizeof(kitu));
cout << "Write data finished" << endl;
ghi.close();
}
file output.dat có thể mở để đọc như file text