[問題] 大量寫檔無法實現
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
問題(Question):
想進行大筆資料檔案處理
要利用CSV檔的特性 逐行讀取
取出可用於 陣列的數值
預期的正確結果(Expected Output):
預期是 每讀一行開一個檔案 檔案編號從0.txt開始
逐一增加
錯誤結果(Wrong Output):
結果只開一個檔案..
程式碼(Code):(請善用置底文網頁, 記得排版)
int main(){
ifstream out;
ofstream in;
int cou=0;
char buffer[9999];
char format[]=".txt";
char c[4];
out.open("Book1.csv");
if(!out)
{
cout<<"file is failed"<<endl;
}else
{
while(!out.eof())
{
out.getline(buffer,sizeof(buffer));
itoa(cou, c, 10);
strcat(c, format);
in.open(format, ios::out);
if(!in) cout << "file is failed " << endl;
in<<buffer;
cou++;
in.close();
cout<<buffer<<endl;
cout<<c;
}
}
system("pause");
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.238.64.122
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1458840834.A.97B.html
→
03/25 01:44, , 1F
03/25 01:44, 1F
謝謝又耍笨了
※ 編輯: kevinqazwsx (36.238.64.122), 03/25/2016 01:51:34
→
03/25 02:23, , 2F
03/25 02:23, 2F
→
03/25 02:24, , 3F
03/25 02:24, 3F
→
03/25 02:25, , 4F
03/25 02:25, 4F
→
03/25 02:27, , 5F
03/25 02:27, 5F
→
03/25 11:05, , 6F
03/25 11:05, 6F
推
03/25 12:27, , 7F
03/25 12:27, 7F
→
03/28 12:09, , 8F
03/28 12:09, 8F
推
03/28 12:52, , 9F
03/28 12:52, 9F
→
03/28 14:20, , 10F
03/28 14:20, 10F