关闭

批量生成文件并写入大量内容

1359人阅读 评论(0) 收藏 举报
分类:
// CreatFile.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include <iostream>
#include<fstream>
#include <string>
using namespace std;

void createFile(string name,string content){

	string path="d:\\"+name+".txt";
	ofstream f1(path);
    if(!f1)return;
	f1<<content<<endl; 
    f1.close();
}

int _tmain(int argc, _TCHAR* argv[])
{
	string  titles[]={"Hinit","HRest1","HRest2","HRest3","HRest4"};
	string content[5];
	string words[]={"yi","er","san","si","wu","liu","qi","ba","jiu","shi","zou","ting","zuo","zhan","ting1","kan","qianjin",
		"houtui","zuozhuan","youzhuan","houzhuan","qili","xiadun","huishou","tiaowu","changge","dingwei","shibie",
		"daiji","shuohua","taitou","xingzou","tingzhi","zhuantou","dazhaohu","dataiji","wangqianzou","xianghoutui",
		"xiangzuozhuan","xiangyouzhuan","zhaoshengyin","jirenlian","yiyanbufa","chayanguanse","shanqiyingren","wenjiqiwu",
		"ertingbafang","taotaobujue","shouzhudaitu","zuoguyoupan"};
	
	  for(int j=0;j<50;j++){
	  content[0]+="Hinit -A -D -T 1 -S training/trainlist_"+words[j]+".txt -M model/hmm0 -H model/proto/hmm_"+words[j]+" -l "+words[j]+" -I training/lab_"+words[j]+".mlf "+words[j]+"\n";
	  content[1]+="HRest -A -D -T 1 -S training/trainlist_"+words[j]+".txt -M model/hmm1 -H model/hmm0/hmm_"+words[j]+" -l "+words[j]+" -I training/lab_"+words[j]+".mlf "+words[j]+"\n";
	  content[2]+="HRest -A -D -T 1 -S training/trainlist_"+words[j]+".txt -M model/hmm2 -H model/hmm1/hmm_"+words[j]+" -l "+words[j]+" -I training/lab_"+words[j]+".mlf "+words[j]+"\n";
	  content[3]+="HRest -A -D -T 1 -S training/trainlist_"+words[j]+".txt -M model/hmm3 -H model/hmm2/hmm_"+words[j]+" -l "+words[j]+" -I training/lab_"+words[j]+".mlf "+words[j]+"\n";
	  content[4]+="HRest -A -D -T 1 -S training/trainlist_"+words[j]+".txt -M model/hmm4 -H model/hmm3/hmm_"+words[j]+" -l "+words[j]+" -I training/lab_"+words[j]+".mlf "+words[j]+"\n";
	  	}
	

	for(int j=0;j<5;j++){
		createFile(titles[j],content[j]);
		}
	return 0;
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:47119次
    • 积分:795
    • 等级:
    • 排名:千里之外
    • 原创:25篇
    • 转载:14篇
    • 译文:4篇
    • 评论:4条