c++读文件,造数据

读文件

	freopen("3.in","r",stdin); //读入,在你的代码的文件夹里需要有这个东西 3.in
	freopen("3.out","w",stdout);//输出,输出怎样的格式看你自己,也可3.txt,如果你的文件夹有这个3.out直接读到里面,如果没有它给你创一个
	

造数据


#include <bits/stdc++.h>
using namespace std; 
char str[100];
int main(){
	std::ios::sync_with_stdio(0); //关闭流同步
	for(int i=1;i<=10;i++){
		sprintf(str,"%d.in",i);  //写文件名
		freopen(str,"wb",stdout); //打开文件或者创个文件,然后在里面写数据
		cout<<str<<endl;//例如这个就是打到里面的数据
	}
	
	return 0;
}


版权声明:本文为qq_37548017原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。