开发平台(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):