作者mangogogo (mangogo)
看板NCTU-STAT95G
标题[转录][心得] fprintf 改档名自动输出
时间Fri Oct 27 12:53:06 2006
※ [本文转录自 NCTU-STAT94G 看板]
作者: catherinejoy (whatcanisay) 看板: NCTU-STAT94G
标题: [心得] fprintf 改档名自动输出
时间: Thu Oct 26 13:26:13 2006
main 里
//export_txt('D:/2006_fall/NHRI','delA',ans,del,item);
printf("Please input the FILE NAME:\n");
scanf("%s",&filename);//输入档名开头
for(i=0;i<del;i++){
sprintf(filename,"%s_%d",filename,i);//filename_i.txt
//path="D:/2006_fall/NHRI/i";
sprintf(path,"%s/%d","D:/2006_fall/NHRI",i);//也可以改路径
export_txt(path,filename,ans,del,item);
printf("\n%s.txt is OK!!!\n",filename);
}//end for i
header
void export_txt(char *path,char *FileName,double **ans,int nrow, int ncol){
char Name[1024];
int i,j;
sprintf(Name,"%s/%s.txt",path,FileName);
out = fopen(Name,"w");
for(i=0;i<nrow;i++){
fprintf(out,"%d\t",i+1);
for(j=0;j<ncol;j++){
fprintf(out,"%3.0lf\t",ans[i][j]);
}//end for j
fprintf(out,"\n");
}//end for i
}
好 请享用...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.114.200
※ 编辑: catherinejoy 来自: 140.113.114.200 (10/26 13:29)
1F:推 littlehana:强者 10/26 17:11
※ 编辑: catherinejoy 来自: 140.113.197.227 (10/27 00:33)
※ 编辑: catherinejoy 来自: 140.113.197.227 (10/27 00:34)
2F:→ catherinejoy:强者是泰宾学长 都是他教导我的 10/27 00:34
3F:推 mangogogo:借转 10/27 12:51
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.114.78