#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream file1;
char str1[]="Hello world";
char num[1]={1};
file1.open("D:\\vc_tmp\\test.dat");
//文本写入
file1<<str1<<endl;
int i=100;
file1<< i <<endl;
//二进制写入 或者用 ios_base::binary
file1.write(str1,strlen(str1));//ASCII
file1.write(num,2); //数字必须调用char数组
file1.close();
// while(1);
return 0;
}
c++ 文本或二进制输出 fstream
最新推荐文章于 2022-10-10 20:14:25 发布