C++txtファイルへのデータ書き込み

4176 ワード

1.プログラム
#include 
#include 
#include 
#include 

using namespace std;

int main(){
	vector<int> forwrite; 
	for(int t = 0; t < 10; t++){
		forwrite.push_back(t);
	}
	ofstream OutFile("./myfile.txt");
	for(int t =0; t < 10; t++){
		char cw = forwrite[t] + '0';
		//            ,             ,        ,     char         
		//OutFile<
		OutFile<< cw <<" ";	
	}
	OutFile<<"
"
; OutFile.close(); return 0; }

2.結果
0 1 2 3 4 5 6 7 8 9