作者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