我是 C++ 新手。我组成了 680x680 的二维数组。我试图将它写入 txt 文件。不幸的是,我不能定期沿着它的维度编写二维数组。我也想从 txt 文件中读取二维数组。我的代码在下面。你能帮帮我吗?
/*Declaration 680 *680 multidimensional array*/
array< array< double >^ >^ arr = gcnew array< array< double >^ >(680);
for (j=0;j<arr->Length;j++){
arr[j]=gcnew array<double>(680);}
/*Write double array to file*/
FILE *OutFile = fopen("C:\\test.txt","w++");
for(n=0;n<=(N-1);n++){
fprintf(OutFile,"\n ");
for(k=0;k<=(N-1);k++){
fprintf(OutFile,"\t %f ",dizi[n][k]);}}
fclose(OutFile);
/* Declaration array reading from file*/
array< array< double >^ >^ read = gcnew array< array< double >^ >(680);
for (j=0;j<read->Length;j++){
read[j]=gcnew array<double>(680);}
/* reading array from file*/
FILE *InFile = fopen("C:\\test.txt","r");
double db;
for(n=0;n<=(N-1);n++){
for(k=0;k<=(N-1);k++){
fscanf(InFile,"\t %f ",&db);
read[n][k]=db; }}
fclose(InFile);
此致...